From: David Abrahams (dave_at_[hidden])
Date: 2003-02-25 11:30:33
Daniel Frey <daniel.frey_at_[hidden]> writes:
> 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;
I would probably never write that. This, however:
template <class T> bool operator( foobar<T> const& );
is just fine.
> This may lead to "accidents" I tried to avoid. We now have to decide
> whether want to allow
I vote 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.
Depends what you're measuring. Number of template instantiations?
Compilation time? Link time? Executable image size? All of these
may be affected.
-- 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