Boost logo

Boost :

From: David Abrahams (david.abrahams_at_[hidden])
Date: 2001-09-15 15:50:45


A possibly more-reliable approach (due, I think, to Peter Dimov) is to
support a conversion to a member function pointer type of a hidden
"implementation detail" class.

-Dave
----- Original Message -----
From: "Daryle Walker" <darylew_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Friday, September 14, 2001 8:26 PM
Subject: [boost] Re: More on the optional class.

> on 9/13/01 8:18 PM, Fernando Cacciola at fcacciola_at_[hidden] wrote:
>
> [SNIP]
> > I also made up my mind about how to let the user test if a given
optional is
> > initialized or not.
> > Previously, optional<> used operator void*() to allow expressions of the
> > form:
> >
> > if ( opt ) or if ( opt != NULL )
> >
> > After *a lot* of consideration, I decided to support only the
'bang-bang'
> > idiom:
> >
> > if ( !!opt ) means initialized.
> > if ( !opt) means uninitialized.
> >
> > I just hope enough people is aware and fond of this very useful
technique,
> > because it removes all the problems with the other approaches.
> > The new optional.hpp header contains a small rational for this design
> > decision.
> [TRUNCATE]
>
> What about this alternative:
>
> You had an "operator void*()" defined for Boolean tests, to avoid the
> integral conversions that "bool" has. However, this property isn't just
> limited to void pointers, it will work for any pointer type. Since your
> class acts kind-of like a smart pointer, why don't you define the Boolean
> operation with "operator T*()" instead! You'll get "operator !()" for
free
> and you could connect it with an "operator *()" and "operator ->()".
>
> --
> Daryle Walker
> Mac, Internet, and Video Game Junkie
> darylew AT mac DOT com
>
>
> Info: http://www.boost.org Unsubscribe:
<mailto:boost-unsubscribe_at_[hidden]>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>
>


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