This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 115e. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2024-11-11


995. Incorrect example for using-declaration and explicit instantiation

Section: 13.9.3  [temp.explicit]     Status: CD2     Submitter: Doug Gregor     Date: 27 Oct, 2009

[Voted into WP at March, 2010 meeting.]

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.

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