Arene Base
Fundamental Utilities For Safety Critical C++
Loading...
Searching...
No Matches
tuple_cat.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_CAT_HPP_
6#define INCLUDE_GUARD_ARENE_BASE_STDLIB_INCLUDE_STDLIB_DETAIL_TUPLE_CAT_HPP_
7
8// parasoft-begin-suppress CERT_CPP-DCL58-a-2 "Part of a standard library implementation"
9// parasoft-begin-suppress AUTOSAR-A17_6_1-a-2 "Part of a standard library implementation"
10
11// IWYU pragma: private, include <tuple>
12// IWYU pragma: friend "stdlib_detail/.*"
13
14#include "arene/base/stdlib_choice/declval.hpp"
15#include "arene/base/stdlib_choice/forward.hpp"
16#include "arene/base/stdlib_choice/tuple_fwd.hpp"
17#include "arene/base/tuple/tuple_cat.hpp"
18#include "arene/base/type_traits/all_of.hpp"
19#include "arene/base/type_traits/is_instantiation_of.hpp"
20#include "arene/base/type_traits/is_invocable.hpp"
21#include "arene/base/type_traits/remove_cvref.hpp"
22
23namespace std {
24
26
27/// @brief Check if a type is a std::tuple or a std::pair
28/// @tparam Tuple The type to check
29/// @return @c true if the @c Tuple is a @c std::tuple or @c std::pair otherwise @c false
30template <class Tuple>
31extern constexpr auto is_std_tuple_or_pair =
32 arene::base::is_instantiation_of_v<arene::base::remove_cvref_t<Tuple>, std::tuple> ||
34
35} // namespace tuple_cat_detail
36
37/// @brief concatenate tuples
38/// @tparam Tuples types of the tuples to concatenate
39/// @param tuples @c std::tuple objects to concatenate
40/// @return @c std::tuple whose elements are the concatenation of @p tuples in order
41///
42/// @pre Every argument must be an @c std::tuple or @c std::pair
43/// Passing non-@c std::tuple tuple-likes to @c std::tuple_cat is undefined
44/// behavior per the standard; use @c arene::base::tuple_cat for those.
45// parasoft-begin-suppress AUTOSAR-M2_10_1-a "Similar names permitted by M2-10-1 Permit #1"
46template <class... Tuples, class = decltype(arene::base::tuple_cat(std::declval<Tuples&&>()...))>
47constexpr auto tuple_cat(Tuples&&... tuples
48) noexcept(arene::base::is_nothrow_invocable_v<decltype(arene::base::tuple_cat), Tuples&&...>)
49 -> decltype(arene::base::tuple_cat(std::forward<Tuples>(tuples)...)) {
50 static_assert(
51 arene::base::all_of_v<tuple_cat_detail::is_std_tuple_or_pair<Tuples>...>,
52 "std::tuple_cat requires every argument to be a std::tuple or std::pair; "
53 "use arene::base::tuple_cat to concatenate arbitrary tuple-like types."
54 );
55 return arene::base::tuple_cat(std::forward<Tuples>(tuples)...);
56}
57// parasoft-begin-suppress AUTOSAR-M2_10_1-a "Similar names permitted by M2-10-1 Permit #1"
58
59} // namespace std
60
61// parasoft-end-suppress AUTOSAR-A17_6_1-a-2
62// parasoft-end-suppress CERT_CPP-DCL58-a-2
63
64#endif // INCLUDE_GUARD_ARENE_BASE_STDLIB_INCLUDE_STDLIB_DETAIL_TUPLE_CAT_HPP_
Definition tuple_cat.hpp:25
constexpr auto is_std_tuple_or_pair
Check if a type is a std::tuple or a std::pair.
constexpr auto tuple_cat(Tuples &&... tuples) noexcept(arene::base::is_nothrow_invocable_v<, Tuples &&... >) ->
concatenate tuples
Definition tuple_cat.hpp:47
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