
Maxim Yegorushkin wrote:
Does it really make any sense making only implementation noncopyable, rather than interface?
This would prevent you from making a copyable implementation of the interface.
If you deal with interfaces only it won't save you from errors like this:
std::auto_ptr<Interface> create() { return std::auto_ptr<Interface>(new Implementation); }
void foo() { std::auto_ptr<Interface> a(create()), b(create());
Assuming you mean boost::shared_ptr here. auto_ptr doesn't work.
*a = *b; // oops, no error here, Implementation::operator= is not considered
This is (1) a no-op, nothing dangerous happens; (2) pretty rare, in my experience. If you really want to catch that, you can make the assignment operator of Interface protected.
}