
5 Oct
2007
5 Oct
'07
5:20 p.m.
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.