Created on 2000-11-02.00:00:00 last changed 197 months ago
[Moved to DR at 4/02 meeting.]
Proposed resolution (04/01):
Replace the first sentence of 13.9 [temp.spec] paragraph 5,
No program shall explicitly instantiate any template more than once, both explicitly instantiate and explicitly specialize a template, or specialize a template more than once for a given set of template-arguments.
by
For a given template and a given set of template-arguments,
- an explicit instantiation shall appear at most once in a program,
- an explicit specialization shall be defined at most once according to 6.3 [basic.def.odr] in a program, and
- both an explicit instantiation and a declaration of an explicit specialization shall not appear in a program unless the explicit instantiation follows a declaration of the explicit specialization.
Replace 13.9.3 [temp.explicit] paragraph 4,
The definition of a non-exported function template, a non-exported member function template, or a non-exported member function or static data member of a class template shall be present in every translation unit in which it is explicitly instantiated.
by
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. Otherwise, the definition of a non-exported function template, a non-exported member function template, or a non-exported member function or static data member of a class template shall be present in every translation unit in which it is explicitly instantiated.
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, or specialize a template more than once for a given set of template-arguments.
This rule has an impact on library issue 120. Library authors would like to have the freedom to specialize (or not) various library functions without having to document their choices, while users need the flexibility to explicitly instantiate library functions in certain translation units.
If this rule could be slightly weakened, it would reduce the need for constraining either the library author or the programmer. For instance, the rule might be recast to say that if a specialization is followed by an explicit instantiation in the same translation unit, the explicit instantiation is ignored. A specialization and an explicit instantiation of the same template in two different translation units would still be an error, no diagnostic required.
History | |||
---|---|---|---|
Date | User | Action | Args |
2008-10-05 00:00:00 | admin | set | status: wp -> cd1 |
2003-04-25 00:00:00 | admin | set | status: dr -> wp |
2002-05-10 00:00:00 | admin | set | messages: + msg694 |
2002-05-10 00:00:00 | admin | set | status: ready -> dr |
2001-11-09 00:00:00 | admin | set | status: review -> ready |
2001-05-20 00:00:00 | admin | set | messages: + msg489 |
2001-05-20 00:00:00 | admin | set | status: open -> review |
2000-11-02 00:00:00 | admin | create |