fork(17) download
  1. #include <iostream>
  2. #include <type_traits>
  3.  
  4. template <typename T, typename std::enable_if< std::is_same<T, int>::value, int >::type = 0>
  5. void foo(T t) {
  6. std::cout << "int" << std::endl;
  7. }
  8.  
  9. template <typename T, typename std::enable_if< !std::is_same<T, int>::value, int >::type = 0>
  10. void foo(T t) {
  11. std::cout << "not int" << std::endl;
  12. }
  13.  
  14. int main(int argc, char* argv[])
  15. {
  16. foo(10);
  17. foo(10.1);
  18. return 0;
  19. }
  20.  
Success #stdin #stdout 0s 2884KB
stdin
Standard input is empty
stdout
int
not int