From: Arkadiy Vertleyb (vertleyb_at_[hidden])
Date: 2007-06-14 11:24:02
"Sebastian Redl" <sebastian.redl_at_[hidden]> wrote
> Arkadiy Vertleyb wrote:
>> Now, I don't know if this is an appropriate topic here, but I would
>> the usefullness of the ODR itself.
> The ODR is a logical necessity, not a feature that may be useful or not.
> If the compiler generates two differing definitions of a symbol, how can
> the linker possibly know which one to use? And if it doesn't know which
> one to use, how can the program have defined behaviour?
> A better question would be whether to relax the ODR such that
> "equivalent" (under specific rules) multiple definitions do not cause
> the ODR to be violated, similar to what is already done for template
>> My main problem with it -- it
>> contradicts to quite useful, IMO, idiom, where a library author defines
>> main template in his/her library as a customization point, and the users
>> provide specializations of this template (similar to virtual functions in
>> runtime world).
> What does this have to do with the ODR?
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.
Another example (from the Typeof library):
Types and templates are mapped to unique numbers using preprocessor counter.
The resulting specializations depend on the order these specializations are
seen by the preprocessor, and therefore on the order of inclusion.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk