In the book "C++ Coding Standards. 101 Rules, Guidelines, and Best Practices" by Herb Sutter and Andrei Alexandrescu in Rule 52, the final quote is:
"In rare cases, classes that have members of strange types (e.g., references, std::auto_ptrs) are an exception because they have peculiar copy semantics. In a class holding a reference or an auto_ptr, you likely need to write the copy constructor and the assignment operator, but the default destructor already does the right thing. (Note that using a reference or auto_ptr member is almost always wrong.)"
It is clear why using references as members is not a good idea (answer to this question is in this post: Should I prefer pointers or references in member data?)
- With regard to a modern C++, does it also mean that using unique_ptr as a class member is usually a bad thing? Or was it a problem only of auto_ptr and missing move semantics maybe?
- Should shared_ptr be used for a polymorphic behavior then?
Thanks in advance!