vendredi 4 août 2017

Default template specialization

I'd like to define functions for integral types, string and other types.

I can write:

template<typename T, typename = std::enable_if<std::is_integral<T>::value>::type>
void foo();

template<typename T, typename = std::enable_if<std::is_same<std::string>::value>::type>
void foo();

But how I can define function that will be called in other cases (if T not integral type and not std::string)?

Aucun commentaire:

Enregistrer un commentaire