Boost logo

Boost :

From: Larry Evans (jcampbell3_at_[hidden])
Date: 2002-10-02 06:51:49


David B. Held wrote:
[snip]

>That is, with my proposal, I believe that the following would work
>correctly, and with negligible side effects:
>
>void g(foo_ptr const& p)
>{
> p->bar();
> p->baz(3); // Error! (Correct)
>}
>
>
>
I haven't looked real close, but doesn't the subsection titled
"Smart Pointers and const" in Item 28 of Scott Meyers
_More Effective C++_ contain a solution to this problem?
Basically, it describes SmartPtr<T> derived from
SmartPtrToConst<T> and SmartPtrToConst<T> containing
a union of const and non-const pointers to T. Unfortunately,
this would require changing shared_ptr.


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