Title
Definition required for explicit instantiation after explicit specialization?
Status
c++11
Section
13.9.3 [temp.explicit]
Submitter
Mike Miller

Created on 2010-09-08.00:00:00 last changed 96 months ago

Messages

Date: 2011-03-15.00:00:00

[Voted into the WP at the March, 2011 meeting as part of paper N3262.]

Date: 2010-11-15.00:00:00

Proposed resolution (November, 2010) [SUPERSEDED]:

Change 13.9.3 [temp.explicit] paragraphs 3-4 as follows:

A declaration of a function template shall be in scope at the point of the explicit instantiation of the function template. A definition of the class or class template containing a member function template shall be in scope at the point of the explicit instantiation of the member function template. A definition of a class template or class member template shall be in scope at the point of the explicit instantiation of the class template or class member template. A definition of a class template shall be in scope at the point of an explicit instantiation of a member function or a static data member of the class template. A definition of a member class of a class template shall be in scope at the point of an explicit instantiation of the member class. A declaration of a function template, a member function or static data member of a class template, or a member function template of a class or class template shall precede an explicit instantiation of that entity. A definition of a class template, a member class of a class template, or a member class template of a class or class template shall precede an explicit instantiation of that entity, unless the explicit instantiation is preceded by an explicit specialization of the entity with the same template arguments. If the declaration of the explicit instantiation names an implicitly-declared special member function (Clause 11.4.4 [special]), the program is ill-formed.

For a given set of template parameters arguments, if an explicit instantiation of a template appears after a declaration of an explicit specialization for that template, the explicit instantiation has no effect. Otherwise...

Date: 2010-09-08.00:00:00

According to 13.9.3 [temp.explicit] paragraph 4,

For a given set of template parameters, if an explicit instantiation of a template appears after a declaration of an explicit specialization for that template, the explicit instantiation has no effect.

However, that does not appear to negate the requirements of paragraph 3 that a definition of the entity being instantiated must be in scope. Consequently, the following would appear to be ill-formed, even though there is no real need for the definition of C:

    template<typename T> class C;
    template<> class C<int> { };
    template class C<int>;
History
Date User Action Args
2014-03-03 00:00:00adminsetstatus: fdis -> c++11
2011-04-10 00:00:00adminsetmessages: + msg3398
2011-04-10 00:00:00adminsetstatus: review -> fdis
2010-11-29 00:00:00adminsetmessages: + msg3111
2010-11-29 00:00:00adminsetstatus: open -> review
2010-09-08 00:00:00admincreate