|
Boost : |
Subject: Re: [boost] safe-bool CRTP class
From: Jeffrey Lee Hellrung, Jr. (jeffrey.hellrung_at_[hidden])
Date: 2011-05-28 17:19:21
On Sat, May 28, 2011 at 1:41 PM, Stephan T. Lavavej <
stl_at_[hidden]> wrote:
> [Jeffrey Lee Hellrung, Jr.]
> > struct _boost_explicit_operator_bool_struct { int _dummy; int member; };
> \
>
> You don't need two data members.
>
According to Andrey Semashev (to whom I credit the technique to, and
should've cited in the above post), you do need two data members, as some
compilers interpret a pointer-to-first-member as equal to 0 (i.e.,
convertible to false). I honestly don't know if such compilers exist or are
technically allowed to do that...
- Jeff
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk