Why should I overload a C++ operator as a global function (STL does) and what are the caveats?
问题 Why would I want to overload a C++ operator() as global and not member function. For example, the == operator. Why is this done? for example in STL libraries. 回答1: The usual rule is for operators which modify the left hand object to be members, and binary operators which return a new object to be free functions; the main motivation for the latter is because the compiler will not convert the left hand side to match a member; if your class supports any implicit conversions, then all of the