Boost logo

Boost :

From: Mathias Gaunard (mathias.gaunard_at_[hidden])
Date: 2007-10-05 13:20:11


Vladimir Batov wrote:
> Given I've been using this Pimpl idiom quite extensively lately [...]
>
> class Test
> {
> public:
>
> Test (int);
> Test (int, int);
>
> int get() const;
>
> bool operator==(Test const& p) const { return impl_ == p.impl_; }
> bool operator!=(Test const& p) const { return impl_ != p.impl_; }
> operator bool() const { return implementation_; }
>
> void swap(pimpl& that) { impl_.swap(that.impl_); }
>
> private:
>
> struct Internal;
> boost::shared_ptr<Internal> impl_;

Why use a boost::shared_ptr? You want your implementation details to be
shared across all 'Test's?
What you need is more like a deep-copying smart pointer.


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