I am trying to implement a class and overload its templated member functions through enable_if
.
class Foo {
public:
template <typename T, typename = enable_if_t<std::is_arithmetic<T>::value>>
void do() {}
template <typename T, typename = enable_if_t<!std::is_arithmetic<T>::value>>
void do() {}
};
Apparently the idea is to separate the instantiation exclusively of T
with respect to arithmetic types. However, the compiler complains about template <class T, class> void do()
cannot be overloaded. How exactly this can happen? What should I do to resolve this problem?
Aucun commentaire:
Enregistrer un commentaire