I'm trying to use std::enable_if_t
and std::is_integral_v
templates to specialize a mem-func of a class. I read this, but it is about common functions instead of member-function.
I mimic it and write my codes as following, but it does NOT work.
namespace oct {
class Class1 {
template< typename T> T memf();
};
template< typename T>
std::enable_if_t< std::is_integral_v<T>, T> Class1::memf() {
std::cout << "Integral." << std::endl;
return 1;
};
template< typename T>
std::enable_if_t < ! std::is_integral_v<T>, T > Class1::memf() {
std::cout << "None-Integral." << std::endl;
return T {};
};
};
Compiling Error Msg:
no declaration matches ‘std::enable_if_t<is_integral_v, T> oct::Class1::memf()