On Jan 24, 2011, at 9:24 AM, Rafael Ávila de Espíndola wrote:

> On 11-01-24 12:17 PM, Douglas Gregor wrote:
>> 
>> On Jan 24, 2011, at 9:08 AM, Renato Golin wrote:
>> 
>>> On 01/24/11 16:40, Rafael Ávila de Espíndola wrote:
>>>> I remember asking this before, but I cannot remember the answer. Is it
>>>> valid for a program to have multiple explicit template instantiations
>>>> with the same arguments?
>>> 
>>> Nope: paragraph 14.7.5
>> 
>> You are technically correct, but the prohibition of multiple explicit 
>> template instantiations is almost useless in practice, because there still 
>> may be any number of implicit template instantiations with the same 
>> arguments.
> 
> Ah, so it is not legal to have multiple explicit instantiations, but it 
> is not required to always have an explicit instantiation declaration in 
> context?

Correct. Remember that explicit instantiation declarations were not available 
in C++98/03, so until C++0x (or if one makes use of extern template in GNU C++) 
there was no way to suppress implicit instantiations.

FWIW, I've had a feature request on my plate for a long time to add an 
attribute "unique_instantiation". The attribute would be applied to the 
explicit instantiation declaration, and would guarantee that the template would 
never be instantiated if it isn't under the control of that explicit 
instantiation declaration. The intent was, of course, to allow us to emit the 
explicit instantiation definition as a strong external (including vtable, RTTI, 
virtual member functions, etc.).

        - Doug
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to