According to the definition of enable_if struct :
template<bool B, class T = void>
struct enable_if {};
template<class T>
struct enable_if<true, T> { typedef T type; };
I am wondering how
template<class T>
T foo(T t, typename std::enable_if<std::is_integral<T>::value >::type* = 0)
{
return t;
}
particularly :
typename std::enable_if<std::is_integral<T>::value >::type
could be invoked without specified type T, in case std::is_integral<T>::value
equal true
. In this case the specialization of std::enable_if will be called and in this definition there is no default template parameter.
Is it due to deduce template parameter mechanism ? If yes why specified a default paramater for not specialization definition ?