0

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?

T.C.
  • 129,563
  • 16
  • 274
  • 404
Jes
  • 2,414
  • 2
  • 23
  • 38
  • 1
    There must be a gazillion dupes out there... default template argument is not part of the signature. Put it in the return type, in the type of a template non-type parameter, or the type of a function parameter (with a default argument) Also, `do` is a keyword. – T.C. May 29 '16 at 04:13
  • And the exact same mistake you made is given as an example of what not to do on cppreference – Rerito May 29 '16 at 08:08

0 Answers0