Boost logo

Boost :

From: Douglas Paul Gregor (gregod_at_[hidden])
Date: 2003-02-25 15:25:10


On Tue, 25 Feb 2003, David Abrahams wrote:
> namespace boost
> {
> struct safe_bool
> {
> int value;
> typedef int safe_bool::*type;
> };
> }
>
> struct myclass
> {
> operator boost::safe_bool::type() const
> {
> return expression ? &boost::safe_bool::value : 0;
> }
> };

You don't want to do that. Add:

struct yourclass
{
  operator boost::safe_bool::type() const
  {
    return expression? &boost::safe_bool::value : 0;
  }
};

myclass m;
yourclass y;

if (m == y) {
  // what's this mean?
}

This is the reason boost::function has poisoned operator== and operator!=.

        Doug


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