Arene Base
Fundamental Utilities For Safety Critical C++
Loading...
Searching...
No Matches
tuple_size.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_TUPLE_SIZE_HPP_
6#define INCLUDE_GUARD_ARENE_BASE_STDLIB_INCLUDE_STDLIB_DETAIL_TUPLE_SIZE_HPP_
7
8// IWYU pragma: private, include <tuple>
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
16namespace std {
17
18/// @brief obtain the number of elements in a tuple-like type
19/// @tparam T tuple like type
20///
21template <class T>
22class tuple_size; // undefined
23
24/// @brief obtain the number of elements in a tuple-like type
25/// @tparam T tuple like type
26///
27/// Specialization for @c const qualified @c T.
28///
29template <class T>
30class tuple_size<T const> : public tuple_size<T> {};
31
32// parasoft-begin-suppress AUTOSAR-A2_11_1-a "This type trait is required to add volatile"
33
34/// @brief obtain the number of elements in a tuple-like type
35/// @tparam T tuple like type
36///
37/// Specialization for @c volatile qualified @c T.
38///
39template <class T>
40class tuple_size<T volatile> : public tuple_size<T> {};
41
42/// @brief obtain the number of elements in a tuple-like type
43/// @tparam T tuple like type
44///
45/// Specialization for @c const and @c volatile qualified @c T.
46///
47template <class T>
48class tuple_size<T const volatile> : public tuple_size<T> {};
49
50// parasoft-end-suppress AUTOSAR-A2_11_1-a
51
52/// @brief obtain the number of elements in a tuple-like type
53/// @tparam T tuple like type
54///
55// NOTE: While most type traits in this 'std' implementation use _v as the source of truth,
56// @c tuple_size_v is based on @c tuple_size as types (including user-defined types) are
57// expected to provide specializations of @c tuple_size.
58template <class T>
59extern constexpr std::size_t tuple_size_v{tuple_size<T>::value};
60
61} // namespace std
62
63#endif // INCLUDE_GUARD_ARENE_BASE_STDLIB_INCLUDE_STDLIB_DETAIL_TUPLE_SIZE_HPP_
constexpr std::size_t tuple_size_v
obtain the number of elements in a tuple-like 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