template <typename T>
typename std::enable_if<std::is_integral<T>::value, T>::type
foo(T t) {
return t * 2;
}
template <typename T>
typename std::enable_if<std::is_floating_point<T>::value, T>::type
foo(T t) {
return t * 3.14;
}
template <typename T, typename = std::enable_if_t<std::is_integral<T>::value>>
class MyClass {
// class implementation
};
template <typename T, typename = std::enable_if_t<std::is_floating_point<T>::value>>
class MyClass {
// class implementation
};
template <typename T>
std::enable_if_t<std::is_integral<T>::value, T>
foo(T t) {
return t * 2;
}
template <typename T>
std::enable_if_t<std::is_floating_point<T>::value, T>
foo(T t) {
return t * 3.14;
}
template <typename T, typename U,
typename = std::enable_if_t<std::is_integral<T>::value && std::is_integral<U>::value>>
void bar(T t, U u) {
// function implementation
}
template <typename T, typename U,
typename = std::enable_if_t<std::is_floating_point<T>::value && std::is_floating_point<U>::value>>
void bar(T t, U u) {
// function implementation
}