The following code:
template <typename T, typename U>
typename std::enable_if<
std::numeric_limits<T>::max() == std::numeric_limits<U>::max(),
bool>::type
same_max() {
return true;
}
template <typename T, typename U>
typename std::enable_if<
std::numeric_limits<T>::max() != std::numeric_limits<U>::max(),
bool>::type
same_max() {
return false;
}
doesn't compile on MSVC2017 (OK on gcc/clang), with the following error:
error C2995: 'std::enable_if<,bool>::type same_max(void)': function template has already been defined
Is this a problem with my SFINAE, or is this a bug in MSVC?
Note: using std::numeric_limits<T>::is_signed
(or std::is_signed<T>::value
) instead of std::numeric_limits<T>::max()
compiles fine:
template <typename T, typename U>
typename std::enable_if<
std::is_signed<T>::value == std::is_signed<U>::value,
bool>::type
same_signedness() {
return true;
}
template <typename T, typename U>
typename std::enable_if<
std::is_signed<T>::value != std::is_signed<U>::value,
bool>::type
same_signedness() {
return false;
}