Boost logo

Boost :

From: Markus Schöpflin (markus.schoepflin_at_[hidden])
Date: 2005-06-29 07:52:12

Christoph Ludwig wrote:

> On Wed, Jun 29, 2005 at 12:59:57PM +0100, John Maddock wrote:
>>>Umm, now I'm confused. Why is explicit instantiation in more than one
>>>translation unit illegal?
>>I think I must be loosing it.... I can't find any such prohibition
>>anywhere.... I was so sure that I'd had problems with this in the past as

> You are referring to the explicit instantiation of the same template
> specialization in several TUs, aren't you?
> That is indeed prohibited. I am too lazy to look for chapter and verse in my
> copy of the standard but Vandevoorde and Josuttis write in "C++ Templates. The
> Complete Guide":
> Section 6.2.1:
> There should be, at most, one explicit instantiation of each distinct entity
> in a program. [...] Not following this rule usually results in linker errors
> that report duplicate definitions of the instantiated entities.

The problem is that the compiler _needs_ the explicit instantiation in
order not to end up with multiple defitions of a static variable used in
the class. And where should that instantiation be written, if not in the

> Section 10.5:
> The standard also specifies that there can be at most one explicit
> instantiation of a certain template specialization in a
> program. Furthermore, if a template specialization is explicitly
> instantiated, it should not be explicitly specialized, and vice versa.

I can't find anything in the standard (14.7) indicating this.


Boost list run by bdawes at, gregod at, cpdaniel at, john at