#include <type_traits>
template<typename Integer,
std::enable_if_t<std::is_integral<Integer>::value>* = 0>
void foo(Integer) {}
template<typename Floating,
std::enable_if_t<std::is_floating_point<Floating>::value>* = 0>
void foo(Floating) {}
int main()
{
foo(3);
}
I2luY2x1ZGUgPHR5cGVfdHJhaXRzPgoKdGVtcGxhdGU8dHlwZW5hbWUgSW50ZWdlciwKICAgICAgICAgc3RkOjplbmFibGVfaWZfdDxzdGQ6OmlzX2ludGVncmFsPEludGVnZXI+Ojp2YWx1ZT4qID0gMD4Kdm9pZCBmb28oSW50ZWdlcikge30KCnRlbXBsYXRlPHR5cGVuYW1lIEZsb2F0aW5nLAogICAgICAgICBzdGQ6OmVuYWJsZV9pZl90PHN0ZDo6aXNfZmxvYXRpbmdfcG9pbnQ8RmxvYXRpbmc+Ojp2YWx1ZT4qID0gMD4Kdm9pZCBmb28oRmxvYXRpbmcpIHt9CgppbnQgbWFpbigpCnsKICAgIGZvbygzKTsKfQ==
prog.cpp: In function ‘int main()’:
prog.cpp:13:10: error: no matching function for call to ‘foo(int)’
foo(3);
^
prog.cpp:5:6: note: candidate: template<class Integer, std::enable_if_t<std::is_integral<_Tp>::value>* <anonymous> > void foo(Integer)
void foo(Integer) {}
^~~
prog.cpp:5:6: note: template argument deduction/substitution failed:
prog.cpp:4:64: error: could not convert template argument ‘0’ to ‘std::enable_if_t<true, void>* {aka void*}’
std::enable_if_t<std::is_integral<Integer>::value>* = 0>
^
prog.cpp:9:6: note: candidate: template<class Floating, std::enable_if_t<std::is_floating_point<_Tp>::value>* <anonymous> > void foo(Floating)
void foo(Floating) {}
^~~
prog.cpp:9:6: note: template argument deduction/substitution failed:
prog.cpp:8:71: note: invalid template non-type parameter
std::enable_if_t<std::is_floating_point<Floating>::value>* = 0>
^