fork download
  1. #include <type_traits>
  2. #include <vector>
  3. #include <string>
  4. #include <iostream>
  5.  
  6. template <typename T, bool bar = false>
  7. struct foo {
  8. static void show()
  9. {
  10. std::cout << "T" << std::endl;
  11. }
  12. };
  13.  
  14. template <typename T>
  15. struct foo<typename std::enable_if<std::is_fundamental<T>::value, std::vector<T>>::type, false> {
  16. static void show()
  17. {
  18. std::cout << "std::vector<fundamental type>" << std::endl;
  19. }
  20. };
  21.  
  22. template <typename T>
  23. struct foo<std::vector<T>, false> {
  24. static void show()
  25. {
  26. std::cout << "std::vector<T>" << std::endl;
  27. }
  28. };
  29.  
  30. int main()
  31. {
  32. foo<int>::show();
  33. foo<std::vector<int>>::show();
  34. foo<std::vector<std::string>>::show();
  35. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:15:8: error: template parameters not deducible in partial specialization:
 struct foo<typename std::enable_if<std::is_fundamental<T>::value, std::vector<T>>::type, false> {
        ^
prog.cpp:15:8: note:         'T'
stdout
Standard output is empty