{
/**
* Equal operator.
*
* \param first first object
* \param second second object
* \return true if two objects are equal; else false
*/
friend bool operator==(const JClass_t& first,
const JClass_t& second)
{
return first.equals(second);
}
/**
* Not equal operator.
*
* \param first first object
* \param second second object
* \return true if two objects are not equal; else false
*/
friend bool operator!=(const JClass_t& first,
const JClass_t& second)
{
return !first.equals(second);
}
};
/**
* Specialisation of class JEquals for two data types.
*
* The first template parameter should have the corresponding member methods:
*
* bool equals(const JFirst_t&) const;
* bool equals(const JSecond_t&) const;
*
* where JFirst_t and JSecond_t refer to the first and second template parameter, respectively.
* The second template parameter may be a primitive data type.
* This class uses in-class friend operators (see Barton-Nackman trick).
*/
template
struct JEquals :
public JEquals
{
/**
* Equal operator.
*
* \param first first object
* \param second second object
* \return true if two objects are equal; else false
*/
friend bool operator==(const JFirst_t& first,
typename JClass::argument_type second)
{
return first.equals(second);
}
/**
* Equal operator.
*
* \param first first object
* \param second second object
* \return true if two objects are equal; else false
*/
friend bool operator==(typename JClass::argument_type first,
const JFirst_t& second)
{
return second.equals(first);
}
/**
* Not equal operator.
*
* \param first first object
* \param second second object
* \return true if two objects are not equal; else false
*/
friend bool operator!=(const JFirst_t& first,
typename JClass::argument_type second)
{
return !first.equals(second);
}
/**
* Not equal operator.
*
* \param first first object
* \param second second object
* \return true if two objects are not equal; else false
*/
friend bool operator!=(typename JClass::argument_type first,
const JFirst_t& second)
{
return !second.equals(first);
}
};
}
#endif