File tree Expand file tree Collapse file tree 1 file changed +13
-3
lines changed
Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -31,26 +31,36 @@ The type query holds the value of the number of dimensions of the array type *`T
3131``` cpp
3232// std__type_traits__rank.cpp
3333// compile with: /EHsc
34+
3435#include < type_traits>
3536#include < iostream>
3637
3738int main ()
38- {
39+ {
3940 std::cout << "rank<int> == "
4041 << std::rank<int>::value << std::endl;
4142 std::cout << "rank<int[5]> == "
4243 << std::rank<int[5]>::value << std::endl;
4344 std::cout << "rank<int[5][10]> == "
4445 << std::rank<int[5][10]>::value << std::endl;
4546
46- return (0);
47- }
47+ int single_dim_array[]{ 1, 2, 3 };
48+ int double_dim_array[2][1]{ { 4 }, { 5 } };
49+
50+ std::cout << "\nrank<decltype(single_dim_array)> == "
51+ << std::rank<decltype(single_dim_array)>::value << std::endl;
52+ std::cout << "rank<decltype(double_dim_array)> == "
53+ << std::rank<decltype(double_dim_array)>::value << std::endl;
54+ }
4855```
4956
5057``` Output
5158rank<int> == 0
5259rank<int[5]> == 1
5360rank<int[5][10]> == 2
61+
62+ rank<decltype(single_dim_array)> == 1
63+ rank<decltype(double_dim_array)> == 2
5464```
5565
5666## Requirements
You can’t perform that action at this time.
0 commit comments