Boost logo

Boost :

Subject: Re: [boost] safe bool operator
From: Domagoj Saric (dsaritz_at_[hidden])
Date: 2010-03-01 16:50:16


"Scott McMurray" <me22.ca+boost_at_[hidden]> wrote in message
news:fa28b9251003011306k77a61047l4e0236ebbd6d8dc3_at_mail.gmail.com...
> Is there a reason it can't just always look at operator!?
>
> I've been using a macro like this, since I don't need the workarounds:
>
> #define OPERATOR_SAFE_BOOL(for_type) \
> typedef bool (for_type::*unspecified_bool_type)() const; \
> operator unspecified_bool_type() const { \
> return !*this ? 0 : &for_type::operator!; \
> }

This forces classes to have operator! and it still suffers from efficiency
issues outlined in the first post...

--
"What Huxley teaches is that in the age of advanced technology, spiritual 
devastation is more likely to come from an enemy with a smiling face than from 
one whose countenance exudes suspicion and hate."
Neil Postman 

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk