From: Daniel Frey (daniel.frey_at_[hidden])
Date: 2003-02-25 10:23:23
Sam Partington wrote:
> 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.
In fact this is what I want to prevent. Consider a global operator! with
a template parameter:
template< typename T > bool operator!( const T& t )
return t.get() == 0;
This may lead to "accidents" I tried to avoid. We now have to decide
whether want to allow it or to prevent it. Sadly you cannot use &T::~T
> Then again, how much does the safe_bool_conversion function cost?
Not much. I think we should find an agreed on goal to achive, the
implementation follows naturally. What do you (and others) think? Should
we allow or prevent non-const-member-function-operator!-implementations?
-- Daniel Frey aixigo AG - financial training, research and technology Schloß-Rahe-Straße 15, 52072 Aachen, Germany fon: +49 (0)241 936737-42, fax: +49 (0)241 936737-99 eMail: daniel.frey_at_[hidden], web: http://www.aixigo.de
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk