Daniel Frey <[EMAIL PROTECTED]> 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>
>> {
>> public:
>>     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

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Reply via email to