
On Mar 10, 2006, at 3:40 PM, Ion GaztaƱaga wrote:
Another option is here: http://www.kangaroologic.com/move_ptr/
static_move_ptr is roughly a C++03 emulation of the proposed unique_ptr.
This static_move_ptr has an advantage I tried to emulate with boost::shmem::scoped_ptr (in the future boost::interprocess::scoped_ptr), which also has a template argument for the deleter (a must to free a shared memory portion allocated with buffer) and a "release" member.
This allows user defined rollback functions using the deleter. You surely can do this with shared_ptr, but sometimes allocating the reference count is an overkill.
I would suggest adding a templatized deleter for scoped_ptr (we don't always need "operator delete" to erase a pointer) or creating a templatized basic_scoped_ptr. The "release" member is in my opinion a good addition to allow rollback semantics (although implementing rollback functors as scoped_ptr deleters is a bit hard, even with bind/lambda). We can propose a rollback_ptr for this if we don't want to change scoped_ptr, although Andrei Alexandrescu's suggestion (on_block_xxx) would be optimal.
Or just accept static_move_ptr into boost? -Howard