
AMDG Vladimir Batov wrote:
Based on the suggestions from Steven Watanabe and Robert Stewart I've uploaded safebool.hpp into the Vault. It can be deployed as
struct Foo { ... operator safebool<Foo>::type() const { return safebool<Foo>(condition); } }; or operator safebool<Foo>::type() const { return safebool<Foo>::make(c); } or operator safebool<Foo>::type() const { return make_safebool<Foo>(c); }
I still like the first one but the other two seemed strong contenders and I realize they might be marginally faster (in theory anyway).
I consider any speed differences to be highly unlikely. IMO, you should pick one interface and stick to it. There is no reason to provide several ways to do the same thing when there are only minor syntactic differences.
Documented the need, the usage and the solution.
In Christ, Steven Watanabe