Arene Base
Fundamental Utilities For Safety Critical C++
Loading...
Searching...
No Matches
rank.hpp
Go to the documentation of this file.
1
// Copyright 2026, Toyota Motor Corporation
2
//
3
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4
5
#ifndef INCLUDE_GUARD_ARENE_BASE_STDLIB_INCLUDE_STDLIB_DETAIL_RANK_HPP_
6
#define INCLUDE_GUARD_ARENE_BASE_STDLIB_INCLUDE_STDLIB_DETAIL_RANK_HPP_
7
8
// IWYU pragma: private, include <type_traits>
9
// IWYU pragma: friend "stdlib_detail/.*"
10
11
// parasoft-begin-suppress CERT_CPP-DCL58-a-2 "Part of a standard library implementation"
12
// parasoft-begin-suppress AUTOSAR-A17_6_1-a-2 "Part of a standard library implementation"
13
14
#include "
stdlib/include/stdlib_detail/cstddef.hpp
"
15
#include "
stdlib/include/stdlib_detail/integral_constant.hpp
"
16
17
namespace
std
{
18
19
/// @brief obtains the number of dimensions of an array type
20
/// @tparam T type to query
21
///
22
/// If @c T is an array type, provides the member constant @c value equal to
23
/// the number of dimensions of the array. For any other type, @c value is 0.
24
///
25
template
<
class
T>
26
extern
constexpr
auto
rank_v
=
size_t
{};
27
28
// NOLINTBEGIN(hicpp-avoid-c-arrays)
29
30
/// @brief obtains the number of dimensions of an array type
31
/// @tparam T type to query
32
///
33
/// If @c T is an array type, provides the member constant @c value equal to
34
/// the number of dimensions of the array. For any other type, @c value is 0.
35
///
36
template
<
class
T>
37
extern
constexpr
auto
rank_v<T[]>
=
rank_v<T>
+ 1;
38
39
/// @brief obtains the number of dimensions of an array type
40
/// @tparam T type to query
41
/// @tparam N array bound
42
///
43
/// If @c T is an array type, provides the member constant @c value equal to
44
/// the number of dimensions of the array. For any other type, @c value is 0.
45
///
46
template
<
class
T,
size_t
N>
47
extern
constexpr
auto
rank_v<T[N]>
=
rank_v<T>
+ 1;
48
49
// NOLINTEND(hicpp-avoid-c-arrays)
50
51
/// @brief obtains the number of dimensions of an array type
52
/// @tparam T type to query
53
///
54
/// If @c T is an array type, provides the member constant @c value equal to
55
/// the number of dimensions of the array. For any other type, @c value is 0.
56
///
57
template
<
class
T>
58
class
rank
:
public
integral_constant
<size_t, rank_v<T>> {};
59
60
}
// namespace std
61
62
#endif
// INCLUDE_GUARD_ARENE_BASE_STDLIB_INCLUDE_STDLIB_DETAIL_RANK_HPP_
std::integral_constant
A helper class to represent a compile-time constant with the specified type and value....
Definition
integral_constant.hpp:23
std::rank
obtains the number of dimensions of an array type
Definition
rank.hpp:58
cstddef.hpp
integral_constant.hpp
std
STL namespace.
std::rank_v
constexpr auto rank_v
obtains the number of dimensions of an array type
stdlib
include
stdlib_detail
rank.hpp
Generated by
1.13.2