fork(1) download
  1. #include<iostream>
  2. #include <vector>
  3.  
  4. template<typename Type, Type v>
  5. struct integral_constant
  6. {
  7. static constexpr Type value =v;
  8. };
  9.  
  10. template<typename>
  11. struct rank
  12. : public integral_constant<std::size_t, 0> { };
  13.  
  14. template<template<typename>class Container,typename Type>
  15. struct rank< Container<Type> >
  16. : public integral_constant<std::size_t, 1 + rank<Type>::value> { };
  17.  
  18. template<class T>
  19. constexpr size_t 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<<dimenstions(vec) << '\n';
  28. return 0;
  29. }
  30.  
Success #stdin #stdout 0s 3296KB
stdin
Standard input is empty
stdout
0