|
Boost : |
From: David Abrahams (dave_at_[hidden])
Date: 2003-04-27 12:26:44
Mike Conley <conley.141_at_[hidden]> writes:
> David Abrahams <dave_at_[hidden]> wrote in
> news:uznmc0wpl.fsf_at_[hidden]:
>
>>> and_<is_const<T>, is_convertible<T,int> >.
>
> OK, this is wrong. What I wanted was a boolean test: is_const<T>::value &&
> is_convertible<T,int>. That's not what and_ does. Duh.
Yes it does.
>> It doesn't matter if it's a template parameter. It's an ODR violation
>> to have:
>
> <snip>
>
>> in the same program, which is essentially the effect if is_whatever
>> uses a context-dependent is_convertible in its body.
>
> Which is why you pass it as a boolean constant template parameter.
> Then you can safely use that parameter in the body. You get the
> context, and there's no ODR violation.
So will it be illegal to build a trait which tests is_convertible on a
dependent type? If so, is_convertible is fragile and dangerous. If
not, then you have to compute is_convertible on a non-dependent type,
which makes is_convertible almost useless.
-- Dave Abrahams Boost Consulting www.boost-consulting.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk