Boost logo

Boost :

From: Howard Hinnant (hinnant_at_[hidden])
Date: 2003-07-01 20:05:06


On Tuesday, July 1, 2003, at 08:21 PM, Schoenborn, Oliver wrote:

>> On Tuesday, Jul 1, 2003, at 17:36 America/Denver, Schoenborn, Oliver
>> wrote:
>>>>
>>>> On Tuesday, Jul 1, 2003, at 14:38 America/Denver, Boost wrote:
>>>>
>>>>> Why is there no strict-ownership smart-pointer in boost?
>>>>> Just curious to know what the reasons are. Thanks,
>>>>
>>>> What do want beyond what boost::scoped_ptr and
>>>> std::auto_ptr provide?
>>>
>>> Ability to be used in STL containers, and explicit transfer of
>>> ownership capabilities (e.g. *no* move-on-copy etc).
>>
>> So what would the copy semantics be?
>
> No copy allowed, except temporarily when inside the container to
> insert or
> re-order or transfer from one container to another.
> Oliver

You may be looking for something that just doesn't exist in the
language yet:

http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/papers/2002/
n1377.htm#move_ptr%20Example

This is a pointer with move semantics only, no copy semantics. And it
does not move with copy syntax. Such a pointer is only a part of the
solution. It also needs containers that know how to deal with a
movable but non-copyable object. And of course language support makes
everything click. :-\

I have experimented (actual working code) with what you're looking for.
  But the tools are *experimental* and not ready for prime time public
use.

NTL ( http://www.ntllib.org/ ) claims to have this today (I think). I
haven't looked at it closely enough to give a good review, but you
might give it a go.

-Howard


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