#include <type_traits>
template<int n>
std::enable_if_t<n == 1, int> f() {}
// OK
template<int n>
std::enable_if_t<n > 1, int> g() {}
// VS2015 : error C2988: unrecognizable template declaration/definition
int main()
{}
I know the error is due to the compiler takes the "greater than" sign '>' as a template termination sign.
My question is: In such a case, how to make the comparison expression legal?
Put the expression in parenthesis:
#include <type_traits>
template<int n>
std::enable_if_t<(n == 1), int> f() { }
template<int n>
std::enable_if_t<(n > 1), int> g() { }
int main() { }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With