
On Apr 26, 2005, at 5:44 PM, Peter Dimov wrote:
Howard Hinnant wrote:
On Apr 26, 2005, at 11:37 AM, Peter Dimov wrote:
ConstPropagation policy (with the default being No for shallow copy and Yes for deep copy).
I've been toying with a smart pointer adaptor for this one. I really haven't fully fleshed out the thinking on it though...
template <class SP> class deep_const
Yes, conversion and checking can be implemented as adaptors, too.
But a really smart pointer would have the right default for const propagation depending on the ownership policy. :-)
Would that be the prescient_ptr? :-) I've got 3 ownership policies on my mind: 1. shared 2. unique 3. cloned And if anything I'm leaning towards shallow const on all of them. However I also believe deep const versions of all of these would probably be valuable as well. And I'm especially looking at signatures like: template<class T, class U> bool operator==(const shared_ptr<T>& a, const shared_ptr<U>& b); shared_ptr today is a shallow const animal, and I think that is good. But the above signature assumes deep const. It would be nice to have a zero-overhead way to express and enforce that assumption. So would it be better to code a const-policy into them all (and whatever other smart pointers crop up)? Or would it be better to make a single adaptor (like stack is for containers), that would take any shallow const smart pointer and adapt it to a deep one? Or maybe there is a third solution that has escaped me. Or perhaps this is an academic problem and really requires no solution. I'm not claiming to know the answer to my question. I'm simply grateful I have a place to ask it. -Howard