I have the following case that works using std::enable_if
:
template<typename T,
typename std::enable_if<std::is_same<int, T>::value>::type* = nullptr>
void f() { }
template<typename T,
typename std::enable_if<std::is_same<double, T>::value>::type* = nullptr>
void f() { }
Now, I saw in cppreference the new syntax, much cleaner in my opinion : typename = std::enable_if_t<std::is_same<int, T>::value>>
I wanted to port my code :
template<typename T,
typename = std::enable_if_t<std::is_same<int, T>::value>>
void g() { }
template<typename T,
typename = std::enable_if_t<std::is_same<double, T>::value>>
void g() { }
But now GCC (5.2) complains :
error: redefinition of 'template<class T, class> void g()'
void g() { }
Why is that so ? What can I do to have the new, more concise syntax in this case if this is possible ?
See Question&Answers more detail:os