From: marchetti alessio (alessio_marchetti_at_[hidden])
Date: 2002-04-02 03:01:17
I was looking at usage patterns of the shared_ptr
template and noticed that most of the times it only
makes sense to create smart pointer objects from
un-named (temporaries) naked pointers:
shared_ptr<int> cp (new int);
The following idiom creates confusion (the ip variable
is not used after the ctor call):
int * ip = new int;
shared_ptr<int> cp ( ip );
The first idiom promotes better encapsulation: do you
think that forcing this usage patterns through
interface would make sense?
It's possible to do that by changing the ctor:
explicit shared_ptr(T * p = 0): px(p), pn(p,
explicit shared_ptr(T * const &p = 0): px(p),
and by adding an additional dummy ctor:
explicit shared_ptr(T * &p): px(p), pn(p,
This change of course breaks source compatibility...
Do You Yahoo!?
Yahoo! Tax Center - online filing with TurboTax
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk