Copy assignment operators and move assignment operators can return anything, including ``++void++``.


However, if you decide to declare them yourself (don't forget the "Rule-of-Zero", S4963), it is a recommended practice to return a non-const reference to the left-operand. It allows the developer to chain the assignment operations, increasing consistency with what other types do, and in some cases enabling writing concise code.


== Noncompliant Code Example

----
class A {
public:
  ~A() = default;
  A(A const &) = default;
  A(A&&) = default;
  const A& operator=(const A& other) ; // Noncompliant
  A operator=(A&& other) noexcept; // Noncompliant
};
----


== Compliant Solution

----
class A {
public:
  ~A() = default;
  A(A const &) = default;
  A(A&&) = default;
  A& operator=(const A& other);
  A& operator=(A&& other) noexcept;
};
----


== See

* https://github.com/isocpp/CppCoreGuidelines/blob/036324/CppCoreGuidelines.md#c60-make-copy-assignment-non-virtual-take-the-parameter-by-const-and-return-by-non-const[{cpp} Core Guidelines C.60] - Make copy assignment non-virtual, take the parameter by const&, and return by non-const&
* https://github.com/isocpp/CppCoreGuidelines/blob/036324/CppCoreGuidelines.md#c63-make-move-assignment-non-virtual-take-the-parameter-by\--and-return-by-non-const-[{cpp} Core Guidelines C.63] - Make move assignment non-virtual, take the parameter by &&, and return by non-const &

