Boost logo

Boost :

From: Sam Partington (sam.partington_at_[hidden])
Date: 2006-03-30 04:25:55


Hi there,

I'm very much in support of new_<>, it seems like an excellent addition. But...

...might it be better for new_<> to return a unique_ptr [1] rather
than an auto_ptr?

You'd get static custom deleter support (which shared_ptr could then
store as a dynamic deleter) :

shared_ptr<T> p = new_<T, null_deleter>();

(I'm not sure how you'd initialise the deleter)

and array support as well :

shared_array<T> collection = new_<T[10]>();

(you'd have to disable unique_ptr<T[]> conversion to shared_ptr, but
allow shared_array conversion)

Sam

[1] N1856
<http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1856.html#Addition%20-%20Class%20template%20unqiue_ptr>
http://tinyurl.com/gchu9


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