Boost logo

Boost :

Subject: Re: [boost] safe-bool CRTP class
From: Krzysztof Czainski (1czajnik_at_[hidden])
Date: 2011-05-28 09:22:14


Thank you all for such large input ;-)

So the way I see it, most of us agree it would be nice to see one official
safe-bool implementation tool in boost.

The first question is: should it be a CRTP class, or should it be a macro,
or both perhaps?

I suggest we talk about the name after we answer the first question ;-) And
later I will try to prepare an implementation with the compiler workarounds
mentioned in this thread.

CRTP class usage:
struct X : public convertible_to_bool<X>
{
  bool operator!() const { return condition; }
  // inherit operator unspecified_bool_t implemented in terms of the above
operator!
};

Macro usage:
BOOST_EXPLICIT_BOOL_OPERATOR() const {
   return ...;
}

I'm not sure how the macro would be implemented, but we'll get to that once
we make the choice.

Right now I feel convinced to the macro version.

Regards
Kris


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