Created on 2012-03-25.00:00:00 last changed 94 months ago
[Moved to DR at the November, 2014 meeting.]
Notes from the April, 2013 meeting:
The proposed resolution interacts with N3649 (generic lambdas), adopted at this meeting, and this issue has returned to "review" status to allow any necessary changes to be made.
Proposed resolution (October, 2012):
Change 13.9.2 [temp.inst] paragraph 1 as follows:
Unless a class template specialization has been explicitly instantiated (13.9.3 [temp.explicit]) or explicitly specialized (13.9.4 [temp.expl.spec]), the class template specialization is implicitly instantiated when the specialization is referenced in a context that requires a completely-defined object type or when the completeness of the class type affects the semantics of the program. [Note: Within a template declaration, a local class or enumeration and the members of a local class are never considered to be entities that can be separately instantiated (this includes their default arguments, exception-specifications, and non-static data member initializers, if any). As a result, the dependent names are looked up, the semantic constraints are checked, and any templates used are instantiated as part of the instantiation of the entity within which the local class or enumeration is declared. —end note] The implicit instantiation of a class template specialization...
Do local classes of function templates get the same treatment as member classes of class templates? In particular, is their definition only instantiated when they are required? For example,
template<typename T> void f() { struct B { T t; }; } int main() { f<void>(); }
Implementations vary on this question.
(This question is superficially similar to the one in issue 1253. However, the entities in view in that issue can be named and defined outside the containing template and thus can be explicitly specialized, none of which is true for local classes of function templates.)
It should also be noted that the resolution of this issue should apply as well to local enumeration types.
History | |||
---|---|---|---|
Date | User | Action | Args |
2017-02-06 00:00:00 | admin | set | status: drwp -> cd4 |
2015-05-25 00:00:00 | admin | set | status: dr -> drwp |
2015-04-13 00:00:00 | admin | set | messages: + msg5416 |
2014-11-24 00:00:00 | admin | set | status: ready -> dr |
2014-03-03 00:00:00 | admin | set | status: review -> ready |
2013-05-03 00:00:00 | admin | set | messages: + msg4322 |
2013-05-03 00:00:00 | admin | set | status: tentatively ready -> review |
2012-11-03 00:00:00 | admin | set | messages: + msg4080 |
2012-11-03 00:00:00 | admin | set | status: open -> tentatively ready |
2012-03-25 00:00:00 | admin | create |