Item-25 Consider support for a non-throwing swap
· ☕ 7 min read

When std::swap would be inefficient for your type,provide a non-throwing swap member function, a non-member swap calling the member, and possibly a specialized std::swap for the case of classes (not templates).


Item-22 Declare data members private
· ☕ 4 min read

Declaring data members private gives clients syntactically uniform access to data, affords fine-grained access control, allows invariants to be enforced, and offers class authors implementation flexibility.


Item-21 Don't return a reference when we have to return an object
· ☕ 6 min read

Never return a pointer or reference to a local stack object, a refenrence to a heap-allocated object, or a pointer or reference to a local static object if there is a change that more than one such object will be needed (item 4 provides a “counter” example that is reasonable in single-threaded environments).