Boost logo

Boost :

From: Joel de Guzman (joel_at_[hidden])
Date: 2003-11-27 02:47:09


Daryle Walker <darylew_at_[hidden]> wrote:
> On 11/24/03 10:47 PM, "Joel de Guzman" <joel_at_[hidden]> wrote:

> BTW, Spirit does have a solution for this problem, right? Otherwise, you
> have a major bug!
>
> (Note that no matter how you define Boolean-conversion, you need to
> explicitly provide operators == and != for your type, "poisoned" if such
> objects aren't supposed to be comparable, and conventional if they are.)

You must've missed this:

Second take:

    template <typename T>
    struct safe_bool
    {
        int* dummy;
        typedef int* safe_bool::*type;
    };

    template <typename T>
    inline typename safe_bool<T>::type
    make_safe_bool(bool cond)
    {
        return cond ? &safe_bool<T>::dummy : 0;
    }

Can you spot some problems with this too?

Cheers,

-- 
Joel de Guzman
http://www.boost-consulting.com
http://spirit.sf.net

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