Arene Base
Fundamental Utilities For Safety Critical C++
Loading...
Searching...
No Matches
concat.hpp
Go to the documentation of this file.
1// Copyright 2024, Toyota Motor Corporation
2//
3// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4
5#ifndef INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_TYPE_LIST_CONCAT_HPP_
6#define INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_TYPE_LIST_CONCAT_HPP_
7
8// IWYU pragma: private, include "arene/base/type_list.hpp"
9// IWYU pragma: friend "(arene/base(?!/tests)|stdlib/include/stdlib_detail)/.*"
10
11#include "arene/base/type_list/type_list.hpp"
12
13namespace arene {
14namespace base {
15
16namespace type_lists {
17
18/// @cond INTERNAL
19
20namespace concat_detail {
21
22/// @brief Local alias for type_list.
23/// @tparam Tn The elements of the list
24template <class... Tn>
25using tl = arene::base::type_list<Tn...>;
26
27/// @brief collapse L0<T...>, .. Ln<U...> into TypeList<T...,
28/// .., U...>
29template <class... Ln>
30struct concat_impl;
31
32/// @brief Concatenating no lists yields an empty list
33template <>
34struct concat_impl<> {
35 /// @brief @p type is an empty list when there are no type-lists to concat
36 using type = tl<>;
37};
38
39/// @brief Concatenating a single list yields that list
40/// @tparam TypeList0 The list template
41/// @tparam T0n The list elements
42template <template <class...> class TypeList0, class... T0n>
43struct concat_impl<TypeList0<T0n...>> {
44 /// @brief @p type is a list of the original elements when there is only
45 /// one type-list and thus nothing to concat
46 using type = TypeList0<T0n...>;
47};
48
49/// @brief Concatenating two lists yields a single list instantiated from the first list template, with the elements
50/// from both of the lists
51/// @tparam TypeList0 The first list template
52/// @tparam T0n The first list elements
53/// @tparam TypeList1 The second list template
54/// @tparam T1n The second list elements
55template <template <class...> class TypeList0, class... T0n, template <class...> class TypeList1, class... T1n>
56struct concat_impl<TypeList0<T0n...>, TypeList1<T1n...>> {
57 /// @brief @p type combines the two type lists into one type list
58 using type = TypeList0<T0n..., T1n...>;
59};
60
61/// @brief Concatenating three or more lists yields a single list instantiated from the first list template, with the
62/// elements from all of the lists
63/// @tparam TypeList0 The first list template
64/// @tparam T0n The first list elements
65/// @tparam TypeList1 The second list template
66/// @tparam T1n The second list elements
67/// @tparam TypeList2 The third list template
68/// @tparam T2n The third list elements
69/// @tparam Ln Any subsequent lists
70template <
71 template <class...>
72 class TypeList0,
73 class... T0n,
74 template <class...>
75 class TypeList1,
76 class... T1n,
77 template <class...>
78 class TypeList2,
79 class... T2n,
80 class... Ln>
81struct concat_impl<TypeList0<T0n...>, TypeList1<T1n...>, TypeList2<T2n...>, Ln...> {
82 /// @brief @p type combines the first two type lists into one type list and
83 /// then recurses into concat when there are at least two type-lists to concat
84 /// @details Keeps @c TypeList0 unchanged so that it is the template that is used for the final result.
85 /// Uses @c tl for all the intermediate lists.
86 using type = typename concat_impl<TypeList0<T0n...>, tl<T1n..., T2n...>, Ln...>::type;
87};
88
89} // namespace concat_detail
90
91/// @endcond
92
93/// @brief collapse L0<T...>, .. Ln<U...> into TypeList<T...,
94/// .., U...>
95///
96/// @tparam Ln A pack of type-lists that holds the types to concatenate.
97/// @return TypeList<T...>
98template <class... Ln>
99using concat = arene::base::type_lists::concat_detail::concat_impl<Ln...>;
100
101/// @brief collapse L0<T...>, .. Ln<U...> into TypeList<T...,
102/// .., U...>
103///
104/// @tparam Ln A pack of type-lists that holds the types to concatenate.
105/// @return TypeList<T...>
106template <class... Ln>
107using concat_t = typename concat<Ln...>::type;
108
109} // namespace type_lists
110} // namespace base
111} // namespace arene
112
113#endif // INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_TYPE_LIST_CONCAT_HPP_
Definition apply_all.hpp:14
Definition array_exceptions_disabled.cpp:11
Copyright 2026, Toyota Motor Corporation.
Definition array_exceptions_disabled.cpp:10