Title
Meaningless template exports
Status
open
Section
10.2 [module.interface]
Submitter
Davis Herring

Created on 2019-11-09.00:00:00 last changed 14 months ago

Messages

Date: 2019-11-09.00:00:00

According to 10.2 [module.interface] paragraph 1, export does not interfere with other definitions; paragraph 3 merely requires that it appear in a declaration that declares at least one name. 13.1 [temp.pre] paragraph 4 prevents using an export-declaration as the declaration of a template-declaration.

With some interpretation, these rules appear to allow various useless constructs like:

   template export void f();
   export template void f();
   export template<> void g(int);
   template<> export void g(int);
   export template<class T> struct trait<T*>;

Simply forbidding them in 10.2 [module.interface] paragraph 3 would also prohibit their appearance in export blocks:

   export {
     template<class> struct A;
     template<class T> struct A<T*>;
   }

It is already the case that the closely-related example

   export {
     template<class T> struct A {A(non_deducible<T>);};
     template<class U> A(U) -> A<find_param<U>>;
   }

is disallowed, although a fix is pending in EWG.

Suggested resolution: Forbid the direct use of the export keyword in these contexts but continue to allow them (and perhaps more) in export { }.

History
Date User Action Args
2019-11-09 00:00:00admincreate