|
Boost : |
Subject: Re: [boost] safe bool not safe enough ?
From: John Maddock (boost.regex_at_[hidden])
Date: 2013-03-14 14:30:14
> bool do_something_with_a_Testable()
> {
> Testable t;
> [...]
> // return t; doesn't work
> return !!t;
> }
That's the whole point: the convertion is explicit so you can't "return t"
and expect an implicit conversion, you need a static_cast if that's what you
*really* want to do:
bool do_something_with_a_Testable()
{
Testable t;
[...]
return static_cast<bool>(t);
}
Which IMO much better expresses what you're trying to do anyway, John.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk