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
17namespace 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///
25template <class T>
26extern 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///
36template <class T>
37extern 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///
46template <class T, size_t N>
47extern 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///
57template <class T>
58class 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_
obtains the number of dimensions of an array type
Definition rank.hpp:58
constexpr auto rank_v< T[N]>
obtains the number of dimensions of an array type
constexpr auto rank_v
obtains the number of dimensions of an array type
constexpr auto rank_v< T[]>
obtains the number of dimensions of an array type
constexpr auto operator()(::arene::base::result< void, E > const &value) const noexcept(noexcept(hash< E >{}(std::declval< E const & >()))) -> std::size_t
Calculate the hash of a result.
Definition result.hpp:1827