fork(1) download
  1. #include <algorithm>
  2. #include <functional>
  3. #include <iostream>
  4. #include <memory>
  5. #include <string>
  6. #include <type_traits>
  7. #include <utility>
  8.  
  9.  
  10. template<typename T>
  11. class SomeClass {
  12. public:
  13. template <class U = T>
  14. std::enable_if_t<std::is_fundamental<U>::value, T>
  15. DoSomething() {
  16. std::cout << "Fundamental\n";
  17. return T();
  18. }
  19.  
  20. template <class U = T>
  21. std::enable_if_t<!std::is_fundamental<U>::value, T>
  22. DoSomething() {
  23. std::cout << "NON-Fundamental\n";
  24. return T();
  25. }
  26. };
  27.  
  28. int main()
  29. {
  30. SomeClass<int> f;
  31. f.DoSomething();
  32. SomeClass<SomeClass<int>> n;
  33. n.DoSomething();
  34. }
Success #stdin #stdout 0s 3140KB
stdin
Standard input is empty
stdout
Fundamental
NON-Fundamental