Skip to content

Commit 837eada

Browse files
authored
Expand example in std::rank reference
1 parent 5b2e9fd commit 837eada

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

docs/standard-library/rank-class.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff 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

3738
int 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
5158
rank<int> == 0
5259
rank<int[5]> == 1
5360
rank<int[5][10]> == 2
61+
62+
rank<decltype(single_dim_array)> == 1
63+
rank<decltype(double_dim_array)> == 2
5464
```
5565

5666
## Requirements

0 commit comments

Comments
 (0)