|
Boost : |
From: Arkadiy Vertleyb (vertleyb_at_[hidden])
Date: 2007-06-14 12:11:56
"Sebastian Redl" <sebastian.redl_at_[hidden]> wrote
> Arkadiy Vertleyb wrote:
>> "Douglas Gregor" <dgregor_at_[hidden]> wrote
>>
>>> That's fine, so long as the template is not instantiated differently in
>>> different translation units.
>> 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.
>>
> The ODR doesn't prohibit techniques, merely occurrences.
>
> If the library specializes the template for its types, then it should do
> so in a way that the specialization is visible whenever the type is
> visible. Otherwise, yes, ODR can occur.
>
> Or, if the library doesn't want to introduce the unavoidable dependency,
> it should document very clearly that, in order to use both this library
> and the library providing the template, the client must include the
> header that provides the specialization.
>
> But this doesn't make the technique invalid.
I would say that, if your technique, as a library author, can easily lead to
the violation of language rules by your users, even though these users don't
do anything obviously wrong, such technique can be defined as invalid.
Regards,
Arkadiy
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk