fork download
  1. #include<iostream>
  2. #include <vector>
  3.  
  4. template<typename Type, Type val>
  5. struct integral_constant
  6. {
  7. static constexpr Type value =val;
  8. };
  9.  
  10. template<typename>
  11. struct rank
  12. : public integral_constant<std::size_t, 0> { };
  13.  
  14. template<typename Type>
  15. struct rank< std::vector<Type> >
  16. : public integral_constant<std::size_t, 1 + rank<Type>::value> { };
  17.  
  18. template<class T>
  19. constexpr size_t vector_dimenstions(T)
  20. {
  21. return rank<T>::value ;
  22. }
  23.  
  24. int main()
  25. {
  26. std::vector<std::vector<std::vector<int>>> vec;
  27. std::cout<<vector_dimenstions(vec) << '\n';
  28. return 0;
  29. }
  30.  
Success #stdin #stdout 0s 3340KB
stdin
Standard input is empty
stdout
3