Skip to content

Commit 9ce3d81

Browse files
Merge pull request #5717 from Rageking8/update-std-rank-reference
Update `std::rank` reference
2 parents 91d5851 + 344fa16 commit 9ce3d81

File tree

1 file changed

+25
-16
lines changed

1 file changed

+25
-16
lines changed
Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,74 @@
11
---
2-
description: "Learn more about: rank Class"
3-
title: "rank Class"
4-
ms.date: "11/04/2016"
2+
title: "rank class"
3+
description: "Learn more about: rank class"
4+
ms.date: 08/28/2025
55
f1_keywords: ["type_traits/std::rank"]
66
helpviewer_keywords: ["rank class", "rank"]
7-
ms.assetid: bc9f1b8f-800f-46ca-b6f4-d8579ed5406a
87
---
9-
# rank Class
8+
# `rank` class
109

1110
Gets number of array dimensions.
1211

1312
## Syntax
1413

1514
```cpp
16-
template <class Ty>
15+
template <class Type>
1716
struct rank;
1817
```
1918

20-
### Parameters
19+
### Template parameters
2120

22-
*Ty*\
21+
*`Type`*\
2322
The type to query.
2423

2524
## Remarks
2625

27-
The type query holds the value of the number of dimensions of the array type *Ty*, or 0 if *Ty* is not an array type.
26+
The type query holds the value of the number of dimensions of the array type *`Type`*, or 0 if *`Type`* is not an array type.
2827

2928
## Example
3029

3130
```cpp
3231
// std__type_traits__rank.cpp
3332
// compile with: /EHsc
33+
3434
#include <type_traits>
3535
#include <iostream>
3636

3737
int main()
38-
{
38+
{
3939
std::cout << "rank<int> == "
4040
<< std::rank<int>::value << std::endl;
4141
std::cout << "rank<int[5]> == "
4242
<< std::rank<int[5]>::value << std::endl;
4343
std::cout << "rank<int[5][10]> == "
4444
<< std::rank<int[5][10]>::value << std::endl;
4545

46-
return (0);
47-
}
46+
int single_dim_array[]{ 1, 2, 3 };
47+
int double_dim_array[2][1]{ { 4 }, { 5 } };
48+
49+
std::cout << "\nrank<decltype(single_dim_array)> == "
50+
<< std::rank<decltype(single_dim_array)>::value << std::endl;
51+
std::cout << "rank<decltype(double_dim_array)> == "
52+
<< std::rank<decltype(double_dim_array)>::value << std::endl;
53+
}
4854
```
4955

5056
```Output
5157
rank<int> == 0
5258
rank<int[5]> == 1
5359
rank<int[5][10]> == 2
60+
61+
rank<decltype(single_dim_array)> == 1
62+
rank<decltype(double_dim_array)> == 2
5463
```
5564

5665
## Requirements
5766

58-
**Header:** \<type_traits>
67+
**Header:** `<type_traits>`
5968

60-
**Namespace:** std
69+
**Namespace:** `std`
6170

6271
## See also
6372

64-
[<type_traits>](../standard-library/type-traits.md)\
65-
[extent Class](../standard-library/extent-class.md)
73+
[`<type_traits>`](type-traits.md)\
74+
[`extent` class](extent-class.md)

0 commit comments

Comments
 (0)