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

2024-04-05


336. Explicit specialization examples are still incorrect

Section: 13.9.4  [temp.expl.spec]     Status: CD1     Submitter: Jason Shirk     Date: 29 Jan 2002

[Voted into WP at April 2003 meeting.]

The examples corrected by issue 24 are still wrong in one case.

In item #4 (a correction to the example in paragraph 18), the proposed resolution is:

  template<class T1> class A {
    template<class T2> class B {
      template<class T3> void mf1(T3);
        void mf2();
      };
  };
  template<> template<class X>
    class A<int>::B { };
  template<> template<> template<class T>
    void A<int>::B<double>::mf1(T t) { }
  template<class Y> template<>
    void A<Y>::B<double>::mf2() { } // ill-formed; B<double> is specialized but
                                    // its enclosing class template A is not

The explicit specialization of member A<int>::B<double>::mf1 is ill-formed. The class template A<int>::B is explicitly specialized and contains no members, so any implicit specialization (such as A<int>::B<double>) would also contain no members.

Proposed Resolution (4/02):

Fix the example in 13.9.4 [temp.expl.spec] paragraph 18 to read:

  template<class T1> class A {
    template<class T2> class B {
      template<class T3> void mf1(T3);
      void mf2();
    };
  };
  template<> template<class X>
    class A<int>::B {
      template<class T> void mf1(T);
    };
  template<> template<> template<class T>
    void A<int>::B<double>::mf1(T t) { }
  template<class Y> template<>
    void A<Y>::B<double>::mf2() { } // ill-formed; B<double> is specialized but
                                    // its enclosing class template A is not