Boost logo

Boost :

From: Arkadiy Vertleyb (vertleyb_at_[hidden])
Date: 2007-06-14 11:51:58


"Douglas Gregor" <dgregor_at_[hidden]> wrote
> Arkadiy Vertleyb wrote:
>> One example:
>>
>> The library author defines a main template;
>> The users A and B provide specializations for their classes;
>> One TU includes the library header, and the header A;
>> Another TU includes the library header, the header A, and B.
>>
>> Now the template is defined differently in different TUs.
>>
> That's fine, so long as the template is not instantiated differently in
> different translation units. The ODR is about the actual use of
> inconsistent definitions. If someone instantiations the primary template
> with a class from A in one TU, and then in another TU instantiations the
> same template with the same class from A, but this time picks up a
> specialization, then we have an ODR violation. Merely the presence of an
> unused specialization does not cause an ODR violation.

And, since the instantiation itself is done by the library user, and the
library author can't know how it will be done, this technique must be
prohibited according to ODR.

Regards,
Arkadiy


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk