Boost logo

Boost Users :

From: Alan M. Carroll, CodeSlinger (yg-boost-users_at_[hidden])
Date: 2002-09-25 11:29:05


I've written my own smart pointer classes but have mostly switched over to
Boost. What I've wondered is why the Boost smart pointers use various
methods to achieve this boolean conversion instead of a single method of the
form

    operator void const * () const { return px; }

This enables the standard boolean uses ("if (ptr)", "if (!ptr)") and also
allows direct comparison between a raw pointer and the shared pointer. It
also doesn't seem to allow bad leakage of the pointer because a (void
const*) can only be used for comparison. I've looked through the news groups
and Boost documentation and seen no mention of this.

"Peter Dimov" <pdimov_at_[hidden]> wrote in message
news:00fd01c2452c$e773aab0$1d00a8c0_at_pdimov2...
> From: "Hickman, Greg" <greg.hickman_at_[hidden]>
> > With Borland 5.5.1, I'm not having any luck using a shared_ptr in a
> boolean
> > context. The compiler complains that the 'if' condition below contains
an
> > "Illegal structure operation". Is this a known deficiency with my
> compiler?
>
> Yes, Borland does have trouble with this construct (i.e. p && q fails),
but
> simple uses such as your program work for me; once again, have you
installed
> the service packs? :-)
>
>


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net