fork download
  1. // Example program
  2. #include <iostream>
  3. #include <string>
  4. #include <type_traits>
  5. #include <complex>
  6.  
  7. typedef std::complex<double> my_type;
  8.  
  9. template<typename T = my_type>
  10. typename std::enable_if<std::is_same<T,double>::value, void>::type
  11. cnt()
  12. {
  13. std::cout<< "Called for double"<<std::endl;
  14. }
  15.  
  16. template<typename T = my_type>
  17. typename std::enable_if<std::is_same<T,std::complex<double>>::value, bool>::type
  18. cnt()
  19. {
  20. std::cout<< "Called for complex<double>"<<std::endl;
  21. return false;
  22. }
  23.  
  24. int main()
  25. {
  26.  
  27. //cnt();
  28. bool b = cnt();
  29.  
  30. }
  31.  
Success #stdin #stdout 0s 3340KB
stdin
Standard input is empty
stdout
Called for complex<double>