Title
Incorrect example for using-declaration and explicit instantiation
Status
cd2
Section
13.9.3 [temp.explicit]
Submitter
Doug Gregor

Created on 2009-10-27.00:00:00 last changed 143 months ago

Messages

Date: 2010-03-15.00:00:00

[Voted into WP at March, 2010 meeting.]

Date: 2010-02-15.00:00:00

Proposed resolution (February, 2010):

Change the example in 13.9.3 [temp.explicit] paragraph 5 as follows:

  namespace N {
    template<class T> class Y { void mf() { } };
  }

  template class Y<int>;            // error: class template Y not visible
                                    // in the global namespace

  using N::Y;
  template class Y<int>;            // OK: explicit instantiation in namespace N
  template class Y<int>;            // error: explicit instantiation outside of the
                                    // namespace of the template

  template class N::Y<char*>;       // OK: explicit instantiation in namespace N
  template void N::Y<double>::mf(); // OK: explicit instantiation
                                    // in namespace N
Date: 2009-10-27.00:00:00

13.9.3 [temp.explicit] paragraph 5 has an example that reads, in significant part,

    namespace N {
      template<class T> class Y {
        void mf() { }
      };
    }

    using N::Y;
    template class Y<int>; // OK: explicit instantiation in namespace N

In fact, paragraph 2 requires that an explicit instantiation with an unqualified name must appear in the same namespace in which the template was declared, so the example is ill-formed.

History
Date User Action Args
2010-03-29 00:00:00adminsetmessages: + msg2740
2010-03-29 00:00:00adminsetstatus: tentatively ready -> cd2
2010-02-16 00:00:00adminsetmessages: + msg2512
2010-02-16 00:00:00adminsetstatus: open -> tentatively ready
2009-10-27 00:00:00admincreate