Boost logo

Boost :

From: Christoph Ludwig (cludwig_at_[hidden])
Date: 2005-06-29 07:35:39

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
> well!

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.
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.




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