JSF.CLASS.DEFINE.OPPOSITE_OPERATOR

When two operators are opposites (such as == and !=), both will be defined and one will be defined in terms of the other.

Rationale

If operator==() is supplied, then one could reasonable expect that operator!=() would be supplied as well. Furthermore, defining one in terms of the other simplifies maintenance.

Example 1

Copy
  bool operator==(Sometype a)
  {
      if ( (a.attribute_1 == attribute_1) &&
              (a.attribute_2 == attribute_2) &&
              (a.attribute_3 == attribute_3) &&
              ...
              (a.attribute_n == attribute_n) )
      {
          return true;
     }
     else
     {
         return false;
     }
     bool operator!=(Some_type a)
     {
         return !(*this==a); //Note “!=” is defined in terms of "=="
     }

The example illustrates how operator!=() may be defined in terms of operator==(). This construction simplifies maintenance.