Boost Safe bool Idiom
-
25% der Zeit verbringt der Programmierer damit festzustellen ob das was er benötigt schon vorhanden ist.
Gibt es eine boost- Basisklasse für das safe bool idiom?
-
In boost kenne ich keine, aber hier ist eine:
http://www.artima.com/cppsource/safebool3.html
-
bool_testable<> in Boost.Operators looks promising.
The reference mentions that:
bool_testable provides the antithesis of operator bool, such that the expression if (!p) is valid, whilst also making operator bool safer by preventing accidental conversions to integer types. ... bool_testable<> prevents these accidental conversions by declaring a private conversion operator to signed char, and not defining the body.