Best practices from the C++ core guidelines: https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md
🔗
F.47: Return T& from assignment operators
The convention for operator overloads (especially on concrete types) is for operator=(const T&) to perform the assignment and then return (non-const) *this. This ensures consistency with standard-library types and follows the principle of "do as the ints do."
🔗
C.60: Make copy assignment non-virtual, take the parameter by const&, and return by non-const&
It is simple and efficient. If you want to optimize for rvalues, provide an overload that takes a && (see F.18).
🔗
C.61: A copy operation should copy
That is the generally assumed semantics. After x = y, we should have x == y. After a copy x and y can be independent objects (value semantics, the way non-pointer built-in types and the standard-library types work) or refer to a shared object (pointer semantics, the way pointers work).