#include <iostream>
template<typename T>
std::enable_if_t<std::is_same<int, T>::value, void> foo() {
std::cout << "foo int\n";
}
template<typename T>
std::enable_if_t<std::is_same<float, T>::value, void> foo() {
std::cout << "foo float\n";
}
int main() {
foo<int>();
foo<float>();
foo<char*>();
}
CSNpbmNsdWRlIDxpb3N0cmVhbT4KCQoJdGVtcGxhdGU8dHlwZW5hbWUgVD4KCXN0ZDo6ZW5hYmxlX2lmX3Q8c3RkOjppc19zYW1lPGludCwgVD46OnZhbHVlLCB2b2lkPiBmb28oKSB7CgkJc3RkOjpjb3V0IDw8ICJmb28gaW50XG4iOwoJfQoJCgl0ZW1wbGF0ZTx0eXBlbmFtZSBUPgoJc3RkOjplbmFibGVfaWZfdDxzdGQ6OmlzX3NhbWU8ZmxvYXQsIFQ+Ojp2YWx1ZSwgdm9pZD4gZm9vKCkgewoJCXN0ZDo6Y291dCA8PCAiZm9vIGZsb2F0XG4iOwoJfQoJCglpbnQgbWFpbigpIHsKCQlmb288aW50PigpOwoJCWZvbzxmbG9hdD4oKTsKCQlmb288Y2hhcio+KCk7Cgl9
prog.cpp: In function 'int main()':
prog.cpp:16:14: error: no matching function for call to 'foo()'
foo<char*>();
^
prog.cpp:16:14: note: candidates are:
prog.cpp:4:54: note: template<class T> std::enable_if_t<std::is_same<int, T>::value, void> foo()
std::enable_if_t<std::is_same<int, T>::value, void> foo() {
^
prog.cpp:4:54: note: template argument deduction/substitution failed:
prog.cpp:9:56: note: template<class T> std::enable_if_t<std::is_same<float, T>::value, void> foo()
std::enable_if_t<std::is_same<float, T>::value, void> foo() {
^
prog.cpp:9:56: note: template argument deduction/substitution failed: