mardi 6 septembre 2016

Check if class/struct has a specific operator

I need to specialise one of my templates and would like to do it depending on the available operator.

I basically need to know if I can do Foo == Bar

template<class T >
std::enable_if_t<has_equalOperator<T>::value> Compare( const T& other )
{
  // can compare using ==
  ...
} 

template<class T >
std::enable_if_t<!has_equalOperator<T>::value> Compare( const T& other )
{
  // cannot compare use some other method
  ...
} 

Does the standard have something similar? If not, how could I implement it?

Aucun commentaire:

Enregistrer un commentaire