Arene Base
Fundamental Utilities For Safety Critical C++
Loading...
Searching...
No Matches
extent.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_EXTENT_HPP_
6#define INCLUDE_GUARD_ARENE_BASE_STDLIB_INCLUDE_STDLIB_DETAIL_EXTENT_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// parasoft-begin-suppress AUTOSAR-A3_9_1-b "The use of 'unsigned' is specified in the standard"
20
21/// @brief obtains the size of an array type along a specified dimension
22/// @tparam T type to query
23/// @tparam N specified array dimension
24///
25/// If @c T is an array type of rank greater than @c N, obtains the bound of the
26/// @c N 'th dimension of @c T as the value. If @c T is an array type of unknown
27/// bound, then the value is 0. In all other cases, value is 0.
28///
29template <class T, unsigned N = 0>
30extern constexpr auto extent_v = size_t{};
31
32// NOLINTBEGIN(hicpp-avoid-c-arrays)
33
34/// @brief obtains the size of an array type along a specified dimension
35/// @tparam T type to query
36///
37/// If @c T is an array type of rank greater than @c N, obtains the bound of the
38/// @c N 'th dimension of @c T as the value. If @c T is an array type of unknown
39/// bound, then the value is 0. In all other cases, value is 0.
40///
41template <class T>
42extern constexpr auto extent_v<T[], 0> = size_t{};
43
44/// @brief obtains the size of an array type along a specified dimension
45/// @tparam T type to query
46/// @tparam N specified array dimension
47///
48/// If @c T is an array type of rank greater than @c N, obtains the bound of the
49/// @c N 'th dimension of @c T as the value. If @c T is an array type of unknown
50/// bound, then the value is 0. In all other cases, value is 0.
51///
52template <class T, unsigned N>
53extern constexpr auto extent_v<T[], N> = extent_v<T, N - 1>;
54
55/// @brief obtains the size of an array type along a specified dimension
56/// @tparam T type to query
57/// @tparam I array bound at dimension 0
58///
59/// If @c T is an array type of rank greater than @c N, obtains the bound of the
60/// @c N 'th dimension of @c T as the value. If @c T is an array type of unknown
61/// bound, then the value is 0. In all other cases, value is 0.
62///
63template <class T, size_t I>
64extern constexpr auto extent_v<T[I], 0> = size_t{I};
65
66/// @brief obtains the size of an array type along a specified dimension
67/// @tparam T type to query
68/// @tparam I array bound at dimension 0
69/// @tparam N specified array dimension
70///
71/// If @c T is an array type of rank greater than @c N, obtains the bound of the
72/// @c N 'th dimension of @c T as the value. If @c T is an array type of unknown
73/// bound, then the value is 0. In all other cases, value is 0.
74///
75template <class T, size_t I, unsigned N>
76extern constexpr auto extent_v<T[I], N> = extent_v<T, N - 1>;
77
78// NOLINTEND(hicpp-avoid-c-arrays)
79
80/// @brief obtains the size of an array type along a specified dimension
81/// @tparam T type to query
82/// @tparam N specified array dimension
83///
84/// If @c T is an array type of rank greater than @c N, obtains the bound of the
85/// @c N 'th dimension of @c T as the value. If @c T is an array type of unknown
86/// bound, then the value is 0. In all other cases, value is 0.
87///
88template <class T, unsigned N = 0>
89class extent : public integral_constant<size_t, extent_v<T, N>> {};
90
91// parasoft-end-suppress AUTOSAR-A3_9_1-b
92
93} // namespace std
94
95#endif // INCLUDE_GUARD_ARENE_BASE_STDLIB_INCLUDE_STDLIB_DETAIL_EXTENT_HPP_
obtains the size of an array type along a specified dimension
Definition extent.hpp:89
constexpr auto extent_v< T[I], N >
obtains the size of an array type along a specified dimension
constexpr auto extent_v
obtains the size of an array type along a specified dimension
constexpr auto extent_v< T[], 0 >
obtains the size of an array type along a specified dimension
constexpr auto extent_v< T[], N >
obtains the size of an array type along a specified dimension
constexpr auto extent_v< T[I], 0 >
obtains the size of an array type along a specified dimension
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