From: Daniel Frey (d.frey_at_[hidden])
Date: 2008-08-10 13:00:06
On Sun, 2008-08-10 at 17:36 +0200, Mathias Gaunard wrote:
> Isaac Dupree wrote:
> > I'm looking at all these "operator unspecified_bool_type"s in Boost.
> > They vary:
> > It's hard to get all of these right, and various Boost libraries have
> > made changes in the past that got it wrong:
> > type-safety
> > compiler workarounds
> > zero runtime overhead (a.k.a. more compiler workarounds)
> At some time, there was a safe-bool thingy in Boost.Operators, but it
> was removed.
> I honestly do not know why.
The code that landed in CVS for a time is not based on the safe-bool
idiom, but on an alternative approach: It simply adds a private
declaration of an "operator signed char() const". When the used
implements "operator bool() const", conversion to bool works while
conversion to other types are ambiguous (e.g. int) or private (e.g.
The problem was that it broke is_convertible:
is_convertible<A,int>::value resulted in a compile-time error instead of
returning false - which is the reason why the code was removed from CVS
before it was ever released.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk