Date
2022-02-18.07:47:23
Message id
607

Content

The syntax for "export" permits it only on template declarations. Clause 13 [temp] paragraph 6 further restricts "export" to appear only on namespace scope declarations. This means that you can't export a member template of a non-template class, as in:

  class A {
    template <class T> void f(T);
  };
You can, of course, put export on the definition:
  export template <class T> void A<T>::f(T){}
but in order for the template to be used from other translation units (the whole point of export) the declaration in the other translation unit must also be declared export.

There is also the issue of whether or not we should permit this usage:

  export struct A {
    template <class T> void f(T);
  };
My initial reaction is to retain this prohibition as all current uses of "export" are preceding the "template" keyword.

If we eliminate the requirement that "export" precede "template" there is a similar issue regarding this case, which is currently prohibited:

  template <class T> struct B {
    export void f();
  };
My preference is still to permit only "export template".