From: Ed Brey (brey_at_[hidden])
Date: 2003-09-08 17:12:53
Daniel Frey wrote:
> Ed Brey wrote:
>> Douglas Gregor wrote:
>> Unless I missed something bool_testable only provides half the
>> problem: it provides operator!, but not the implicit bool
> I hope you missed something, because bool_testable means that you
> an operator bool() yourself and bool_testable makes it as safe as the
> safe-bool-idiom. You have to provide something anyway, so why not the
> most obvious operator bool() as this is actually what you are trying
> to achive, isn't it? The problem is usually that this is not safe enough,
> but bool_testable provides exactly that.
Indeed it does. I looked at bool_testable too quickly before, just looking at the public member and not really thinking through its place in the operators library. It is quite nice to have the real operator bool(), rather than goofing around with pointers.
What's really neet is that it handles the comparison case. That is, "p1 == p2" leads to ambiguity and a compilation error. I think it would be great to see the appropriate boost libraries using this.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk