Boost logo

Boost :

From: Larry Evans (jcampbell3_at_[hidden])
Date: 2002-10-03 17:48:32


David B. Held wrote:
[snip]

>template <typename T>
>class ptr;
>
>template <typename T>
>class ptr<T const>
>{
>public:
> ptr() { }
> T const* operator->() const { return p_; }
>private:
> ptr(ptr const&);
> T* p_;
>};
>
>template <typename T>
>class ptr : public ptr<T const>
>{
>
>
[snip]

>and thereby modify p. However, this is true in general, and I don't think
>it presents a significant risk. This is an interesting idiom, and I would
>like to hear other people's comments on it. Not worth the complexity?
>Hidden problems/risks?
>
>
>
I think its close to perfect if not perfect! This is better than
Meyer's solution. Maybe Meyers didn't have
a compiler that could specialize on `const T` and `T`.


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