Boost logo

Boost :

From: Anthony Williams (anthony_w.geo_at_[hidden])
Date: 2002-01-10 02:39:41


From: "Andrei Alexandrescu" <andrewalex_at_[hidden]>
Sent: Wednesday, January 09, 2002 11:37 PM
> If you really want that, I think it's better to implement a limited
> arithmetic than opening the floodgates by allowing conversions. There's
> smart pointer arithmetic that doesn't make sense, for example subtraction
of
> unsigned integers. I haven't studied the problem too much yet, but I guess
> you can implement arithmetic even without allowing automatic conversion.

Indeed you can --- see my GenericPtr code and article from Overload
(http://cplusplus.anthonyw.cjb.net/articles.html)

This enables pointer arithmetic on a GenericPtr without accidentally
deallocating the array --- given a GenericPtr<int> "gpi" that points to an
array, gpi+3 is a new GenericPtr<int> that also points to the array, and
increments the reference count. Only when both pointers die is the array
freed.

Anthony


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


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