Reputation: 5993
I am using the BOOST_STRONG_TYPEDEF
macro, which creates a class that overloads operator==
. I'm wondering if I need to overload operator!=
as well?
Upvotes: 4
Views: 124
Reputation: 1293
Well, no. These operators are totally independent, you can overload one but not the another if you don't use it
Upvotes: 2
Reputation: 5993
Answer: no!
The reason (that I didn't notice at first) is that BOOST_STRONG_TYPEDEF uses Boost operators (http://www.boost.org/doc/libs/1_38_0/libs/utility/operators.htm), specifically totally_ordered1 and totally_ordered2. So the less than and equality comparison operators are implemented for you.
Upvotes: 5