Boost logo

Boost :

From: Kevin Atkinson (kevinatk_at_[hidden])
Date: 2000-03-18 01:38:04


Dave Abrahams wrote:
>
> on 3/17/00 5:34 PM, Greg Colvin at gcolvin_at_[hidden] wrote:
>
> > The impasse is that some users of smart pointers, myself
> > included, actually want operator T*(). If you have generic
> > code written to accept pointers then operator void*() won't
> > do, and neither will get().
> >
>
> Ya know, I don't think I buy it. Could you give an example?
>
> If you mean generic code as in "template code", it will just use the smart
> pointer type instead, and no implicit conversion is needed

Or if you want to pass the pointer to a function. Or if you want to
store the pointer in a temporary location in a function but you KNOW the
lifetime of the temparay pointer thus a smart pointer is overkill,
etc.., etc... I do it ALL the time with my CopyPtr and ClonePtr. And
using get() all the time gets to be annoying.

Unlike with a string converting to const char *. The conversion is
generally safe as the contractor which expects a pointer is made
explicit thus it can not accidently be converted back into a smart
pointer (which WOULD weak havoc as two different smart pointers think
they OWN the same pointer).

-- 
Kevin Atkinson
kevinatk_at_[hidden]
http://metalab.unc.edu/kevina/

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