std::auto_ptr or boost::shared_ptr for pImpl idiom?
问题 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 more exception friendly? class Foo { public: Foo(); private: struct impl; std::auto_ptr<impl> impl_; }; class Foo { public: Foo(); private: struct impl; boost::shared_ptr<impl> impl_; }; [EDIT] Is it always safe to use std::auto_ptr<> or are there situations when an alternative boost smart pointer is required? 回答1: You shouldn't really use std::auto