language: C++11 (gcc-4.7.2)
date: 265 days 2 hours ago
link:
visibility: public
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <iostream>
#include <type_traits>
 
template <typename T, typename std::enable_if< std::is_same<T, int>::value, int >::type = 0>
void foo(T t) {
  std::cout << "int" << std::endl;
}
 
template <typename T, typename std::enable_if< !std::is_same<T, int>::value, int >::type = 0>
void foo(T t) {
  std::cout << "not int" << std::endl;
}
 
int main(int argc, char* argv[])
{
  foo(10);
  foo(10.1);
  return 0;
}