How do I template overload an operator for a group of related classes without conflicting with standard library operators?
问题 This seems like a fairly straight forward idea: I have a group of classes for which I should be able to write an operator, let's say subtraction, using basically the exact same code. When trying to do this the "obvious" way, i.e: template <typename T> T operator-(T a, const T& b) { return a -= b; } Then, on certain compilers, this seems to conflict with a subtraction operator for iterators (specifically it breaks on gcc 3.4.6 and Apple LLVM, while seemingly working fine on gcc version 4 or