fork download
  1. #include <iostream>
  2. #include <string>
  3. #include <vector>
  4. #include <array>
  5. #include <type_traits>
  6.  
  7. template<typename T>
  8. struct is_container
  9. {
  10. static const bool value = false;
  11. };
  12.  
  13. template<typename T , size_t N>
  14. struct is_container<std::array<T , N>>
  15. {
  16. static const bool value = true;
  17. };
  18.  
  19. template<typename T , typename Alloc>
  20. struct is_container<std::vector<T , Alloc>>
  21. {
  22. static const bool value = true;
  23. };
  24.  
  25. template<typename T , typename Enable = void>
  26. struct is_container_sequence
  27. {
  28. static const bool value = false;
  29. };
  30.  
  31. template<typename T>
  32. struct is_container_sequence<T , typename std::enable_if<is_container<T>::value>::type>
  33. {
  34. static const bool value = true;
  35. };
  36.  
  37. int main()
  38. {
  39. std::vector<int> vec1;
  40. std::vector<std::string> vec2;
  41.  
  42. std::cout << is_container_sequence<std::vector<int>>::value
  43. << is_container_sequence<std::vector<std::string>>::value
  44. << std::is_pod<int>::value;
  45. }
  46.  
Success #stdin #stdout 0s 3340KB
stdin
Standard input is empty
stdout
111