Title
Requiring explicit instantiation declarations
Status
nad
Section
13.9.3 [temp.explicit]
Submitter
Doug Gregor

Created on 2010-03-05.00:00:00 last changed 174 months ago

Messages

Date: 2010-08-15.00:00:00

Rationale (August, 2010):

CWG prefers the current specification.

Date: 2022-11-20.07:54:16

The current language specification allows suppression of implicit instantiations of templates via an explicit instantiation declaration; if all uses of a particular specialization follow an explicit instantiation declaration for that specialization, and there is one explicit instantiation definition in the program, there will be only a single copy of that instance. However, the Standard does not require the presence of an explicit instantiation declaration prior to use, so implementations must still be prepared (using weak symbols, for example) to handle multiple copies of the instance at link time. This can be a significant overhead, particularly in shared libraries where weak symbols must be resolved at load time. Requiring the presence of an explicit instantiation declaration in every translation unit in which the specialization is used would allow the compiler to emit strong symbols for the explicit instantiation definition and reduce the overhead.

On the other hand, the current definition allows use of multiple independent libraries with explicit instantiation directives of the same specializations (from a common third-party library, for instance), as well as incremental migration of libraries to use of explicit instantiation declarations rather than requiring all libraries to be updated at once.

History
Date User Action Args
2010-08-23 00:00:00adminsetmessages: + msg2954
2010-08-23 00:00:00adminsetstatus: open -> nad
2010-03-05 00:00:00admincreate