Given a class declaration
class A {
template <typename T> T foo();
};
I would like to specialize A::foo
for various types (int
, ...) and type classes (POD, non-POD) of T
. Unfortunately, I cannot seem to use std::enable_if
for the latter. The following doesn't compile:
template <> int A::foo<int>(); // OK
template <typename T>
typename std::enable_if<is_pod<T>::value, T>::type foo(); // <<<< NOT OK!
template <typename T>
typename std::enable_if<!is_pod<T>::value, T>::type foo(); // <<<< NOT OK!
The issue is probably due to the std::enable_if<...>
stuff being part of the function signature, and that I did not declare any such member inside A
. So how can I specialize a template member based on type traits?