Can refactoring an overloaded operator into a non-member function break any code?
问题 Consider a legacy class template with overloaded addition operators += and + template<class T> class X { public: X() = default; /* implicict */ X(T v): val(v) {} X<T>& operator+=(X<T> const& rhs) { val += rhs.val; return *this; } X<T> operator+ (X<T> const& rhs) const { return X<T>(*this) += rhs; } private: T val; }; Upon code review, it is observed that + is implementable in terms of += , so why not make it a non-member (and have guaranteed symmetry for left and right arguments)? template