This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 119a. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.
2025-12-20
[Moved to DR at 4/02 meeting.]
According to 13.9 [temp.spec] paragraph 5,
No program shall explicitly instantiate any template more than once,both explicitly instantiate and explicitly specialize a template, orspecialize a template more than once for a given set oftemplate-arguments.
This rule has an impact on library issue 120. Library authorswould like to have the freedom to specialize (or not) variouslibrary functions without having to document their choices, whileusers need the flexibility to explicitly instantiate libraryfunctions in certain translation units.
If this rule could be slightly weakened, it would reduce the needfor constraining either the library author or the programmer. Forinstance, the rule might be recast to say that if a specialization isfollowed by an explicit instantiation in the same translation unit,the explicit instantiation is ignored. A specialization and anexplicit instantiation of the same template in two differenttranslation units would still be an error, no diagnostic required.
Proposed resolution (04/01):
Replace the first sentence of 13.9 [temp.spec] paragraph 5,
No program shall explicitly instantiate any template morethan once, both explicitly instantiate and explicitlyspecialize a template, or specialize a template more thanonce for a given set oftemplate-arguments.
by
For a given template and a given set oftemplate-arguments,
- an explicit instantiation shall appear at most once in aprogram,
- an explicit specialization shall be defined at most onceaccording to 6.3 [basic.def.odr] in a program, and
- both an explicit instantiation and a declaration of anexplicit specialization shall not appear in a program unlessthe explicit instantiation follows a declaration of the explicitspecialization.
Replace 13.9.3 [temp.explicit] paragraph 4,
The definition of a non-exported function template, a non-exportedmember function template, or a non-exported member function orstatic data member of a class template shall be present in everytranslation unit in which it is explicitly instantiated.
by
For a given set of template parameters, if an explicitinstantiation of a template appears after a declaration ofan explicit specialization for that template, the explicitinstantiation has no effect. Otherwise, the definition of anon-exported function template, a non-exported memberfunction template, or a non-exported member function or staticdata member of a class template shall be present in everytranslation unit in which it is explicitly instantiated.