fork download
  1. #include <type_traits>
  2. #include <string>
  3. #include <iostream>
  4.  
  5. template<class T>
  6. typename std::enable_if<!std::is_convertible<T, std::string>::value, void>::type
  7. fn(T t)
  8. {
  9. std::cout << "base" << std::endl;
  10. }
  11.  
  12. template<class T>
  13. typename std::enable_if<std::is_convertible<T, std::string>::value, void>::type
  14. fn(T t)
  15. {
  16. std::cout << "string" << std::endl;
  17. }
  18.  
  19. int main()
  20. {
  21. fn("hello");
  22. fn(std::string("new"));
  23. fn(1);
  24. }
Success #stdin #stdout 0s 3028KB
stdin
Standard input is empty
stdout
string
string
base