Boost logo

Boost :

Subject: Re: [boost] BOOST_EXPLICIT_OPERATOR_BOOL macro?
From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2010-04-23 09:34:43


On 04/23/2010 10:28 AM, Jeffrey Hellrung wrote:
> Andrey Semashev wrote:
>> I think such a tool would be useful. But I found it more convenient to
>> express explicit operator bool through operator!. This allows the
>> check to be arbitrarily complex, and the approach adds to
>> compatibility with some compilers. See here:
>>
>> <http://boost-log.svn.sourceforge.net/viewvc/boost-log/trunk/boost-log/boost/log/detail/unspecified_bool.hpp?revision=432&view=markup>
>
>
> Can you explain why the dummy struct has *two* data members? Is it
> because some compilers interpret a pointer-to-member-object to the first
> data member of a class as convertible to false?

Yes. Apparently, some compilers use offset to the data member as the
underlying representation of the member data pointer, which is zero for
the first data member.


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