Boost logo

Boost :

Subject: Re: [boost] safe bool operator
From: Peter Dimov (pdimov_at_[hidden])
Date: 2010-03-01 15:41:19


Domagoj Saric wrote:
> It enables a one liner implementation for a safe_bool operator:
>
> class my_class
> {
> public:
> bool some_is_valid_function() const;
> operator boost::unspecified_bool_type() const { return
> boost::make_safe_bool( some_is_valid_function() ); }

Using a single type allows unrelated classes to compare equal with
operator==.


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