In a comparison operator:
template
bool operator==(Manager m1, Manager m2) {
return m1.internal_field == m2
You can use boost's typetraits (is_base_of), and boost's enable_if.
#include
#include
template
struct has_derived_base_relationship :
boost::integral_constant<
bool, boost::is_base_of::value || boost::is_base_of::value
>
{};
template
typename boost::enable_if, bool>::type
operator==(Manager m1, Manager m2) {
return p1.internal_field == p2.internal_field;
}
On the other hand, why would operator== usage have more value with types of the same inheritance tree? Wouldn't it have to use double dispatch to achieve meaningful results?