Allowing export on template members of nontemplate classes
Clause [13] [temp]
John Spicer

Created on 2002-01-30.00:00:00 last changed 161 months ago


Date: 2003-04-15.00:00:00

[Voted into WP at April 2003 meeting.]

Date: 2002-04-15.00:00:00

Notes from the 4/02 meeting:

This is resolved by the proposed changes for issue 323.

Date: 2020-12-15.00:00:00

The syntax for "export" permits it only on template declarations. Clause 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".

Date User Action Args
2008-10-05 00:00:00adminsetstatus: wp -> cd1
2003-04-25 00:00:00adminsetmessages: + msg870
2003-04-25 00:00:00adminsetstatus: ready -> wp
2002-11-08 00:00:00adminsetstatus: review -> ready
2002-05-10 00:00:00adminsetmessages: + msg631
2002-05-10 00:00:00adminsetstatus: open -> review
2002-01-30 00:00:00admincreate