erratum for GotW #62
(pimpl-idiom and std::auto_ptr)
Sutter's page for the guru question GotW #62 reads:
"... this is not so good if Y is a Pimpl, for example, and the whole point is to hide Y's definition from clients of X2".
solution
If you use a forward-decl. for Y you don't need to show around the def. for Y
-
when using
std::auto_ptrandboost::scoped_ptryou must provide an empty implementation of the X2-destructor because the default generated destructor would leak memory. See X2.h and X2.C. (Björn Karlsson, Beyond the Standard Library) -
when using a
boost::shared_ptranything works right out of the box. (Scott Meyers, Efficient C++, 3rd edition)