Boost logo

Boost :

From: Douglas Paul Gregor (gregod_at_[hidden])
Date: 2003-11-28 11:07:50


On Fri, 28 Nov 2003, David Abrahams wrote:

> Daniel Wallin <dalwan01_at_[hidden]> writes:
>
> >> Personally, I like Joel de Guzman's version, but I also like using
> >> boost
> >> operators, so for me a mix of the two would be good:
> >> [snip]
> >
> > Here's another one:
> >
> > template <class T>
> > struct bool_testable
> > {
> > protected:
> > bool_testable()
> > {
> > BOOST_STATIC_ASSERT(!(
> > boost::is_convertible<T, int>::value)
> > );
> > }
>
> Anything based on this technique will unfortunately fail when T has a
> private conversion to int.

So will any attempts to use that type in a boolean context, because the
int overload will be selected. If you need a conversion to int, you can't
use bool_testable.

        Doug


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