25% of programmers work time is spended by checking if the required code already exist.
I'm searching for a base class for implementing the safe bool idiom.
bool_testable<>
in Boost.Operators looks promising.
The reference mentions that:
bool_testable
provides the antithesis ofoperator bool
, such that the expressionif (!p)
is valid, whilst also makingoperator 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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With