A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://cplusplus.com/reference/type_traits/rank/ below:

class template

<type_traits>

std::rank
template <class T> struct rank;

Array rank


Trait class to obtain the rank of type T.

The rank of an array type is its number of dimensions. For other types is zero.

The class is derived from integral_constant.



Template parameters
T
A type.

Member types Inherited from integral_constant:
member type definition value_type A type capable of representing non-negative integer values type An instantiation of integral_constant
Member constants Inherited from integral_constant:
member constant definition value The rank of T
Member functions Inherited from integral_constant:
operator value_type
Returns value (public member function)

Example
1
2
3
4
5
6
7
8
9
10
11
12
// array rank example
#include <iostream>
#include <type_traits>

int main() {
  std::cout << "rank:" << std::endl;
  std::cout << "int: " << std::rank<int>::value << std::endl;
  std::cout << "int[]: " << std::rank<int[]>::value << std::endl;
  std::cout << "int[][10]: " << std::rank<int[][10]>::value << std::endl;
  std::cout << "int[10][10]: " << std::rank<int[10][10]>::value << std::endl;
  return 0;
}

Possible output:
rank:
int: 0
int[]: 1
int[][10]: 2
int[10][10]: 2


See also
extent
Array dimension extent (class template)
alignment_of
Alignment of (class template)

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4