What is the difference of these two implementations and which of them should I use, since whey both work the same if I call them from main:
template<class T, typename std::enable_if<std::is_integral<T>::value, int>::type = 0>
void test( const T& t ){
printf("int\n");
}
template<class T, typename std::enable_if<std::is_floating_point<T>::value, int>::type = 0>
void test( const T& t ){
printf("float\n");
}
vs
template<class T>
typename std::enable_if<std::is_integral<T>::value>::type test1( const T& t ){
printf("int\n");
}
template<class T>
typename std::enable_if<std::is_floating_point<T>::value>::type test1( const T& t ){
printf("float\n");
}
and the main:
int main(){
test(1);
test(1.0);
test1(1);
test1(1.0);
}