When using the pImpl idiom is it preferable to use a boost:shared_ptr
instead of a std::auto_ptr
? I\'m sure I once read that the boost version is
If you are being really pedantic there is no absolute guarantee that using an auto_ptr
member does not require a full definition of the auto_ptr
's template parameter at the point at which it is used. Having said that, I've never seen this not work.
One variation is to use a const auto_ptr
. This works so long as you can construct your 'pimpl' with a new expression inside the initialiser list and guarantees that the compiler cannot generate default copy constructor and assignment methods. A non-inline destructor for the enclosing class still needs to be provided.
Other things being equal, I would favour an implementation that uses just the standard libraries as it keeps things more portable.