Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2003-04-27 10:46:46

Mike Conley <conley.141_at_[hidden]> writes:

> David Abrahams <dave_at_[hidden]> wrote in
> news:ubrys7jp1.fsf_at_[hidden]:
>> That completely scuttles the ODR, as far as I can tell.
> Naturally, you wouldn't want to use a built in is_convertible this way.
> Better to pass it as a template parameter directly, rather than wrapping
> it: and_<is_const<T>, is_convertible<T,int> >.
> If you know that the result of is_convertible depends on context, and you
> know about the ODR, then you know not to use is_convertible to as part of a
> metafunction's return value without also making it part of the
> metafunction's type (ie, using it as a template parameter).

It doesn't matter if it's a template parameter. It's an ODR violation
to have:

    template <>
    struct is_whatever<X>
       static bool const value = false;


    template <>
    struct is_whatever<X>
       static bool const value = true;

in the same program, which is essentially the effect if is_whatever
uses a context-dependent is_convertible in its body.

Dave Abrahams
Boost Consulting

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