It's a late answer, but I'm only active on Stack Overflow for a short time and I just found your question. I am the maintainer of Boost.Operators and I removed bool_testable
back in December 2003 before it could accidentially be released.
Sam Partington proposed it a few weeks earlier and I added it to the CVS repository. It looked promising in the beginning, but soon problems showed up in certain scenarious.
The main problem, IIRC, for a class T
derived from boost::bool_testable<T>
had to do with conversion detection. A class which is convertible to bool
, but not to int
, should yield boost::is_convertible<T,int>::value == false
, but instead, it became ambiguous and you ended up with a compile failure.
There were also other issues and solving one of them usually implied breaking another. One example involved types where the user wanted explicit conversion to bool
and his own operator int()
.
So, long story short, we never figured out how to make it robust enough. In case of doubt, the benefit was too small (safe ~5 lines of copy-paste code) compared with the potential problems, that I decided to play it safe and hence I removed it.
After it was removed, the issue never came up again and people eventually started to either copy-paste the Safe-Bool-Idiom code to their classes, or (some time later) they started to use explicit operator bool()
as it became available.
That said, it's best if you just copy the lines manually. I know it's not an elegant solution and I don't like copy-paste either, but the alternatives were all worse than that.
bool_testable
was added, but then removed shortly after and never existed in a release (reference). In what version of boost did you see it? – Cravens