From: David Abrahams (dave_at_[hidden])
Date: 2003-02-25 09:55:05
"Sam Partington" <Sam.Partington_at_[hidden]> writes:
> I thought of this too, but this limits the user to using a member based
> operator!. So I couldn't do this :
> class A : public boost::bool_testable<A>
> int get();
> bool operator!(const A& a)
> return a.get() == 0;
> Of course I've never actually wanted to do that, so its maybe not a problem.
> After all the conversion operator itself has to be a member, so it probably
> isn't much of a restriction at all.
Ahem. The operators library is *all about* defining free function
operators. I don't think you should introduce a dependence on being
a member function.
> Then again, how much does the safe_bool_conversion function cost?
More than I'd like. I'd prefer to use a single data member pointer,
since it's likely to be more efficient.
template <class T, class B> friend class bool_testable;
typedef int safe_bool::*type;
-- Dave Abrahams Boost Consulting www.boost-consulting.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk