| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | //====================================================================================================================== | ||
| 2 | /* | ||
| 3 | KUMI - Compact Tuple Tools | ||
| 4 | Copyright : KUMI Project Contributors | ||
| 5 | SPDX-License-Identifier: BSL-1.0 | ||
| 6 | */ | ||
| 7 | //====================================================================================================================== | ||
| 8 | #pragma once | ||
| 9 | |||
| 10 | namespace kumi | ||
| 11 | { | ||
| 12 | namespace _ | ||
| 13 | { | ||
| 14 | template<typename T, typename Seq, std::size_t... I> | ||
| 15 | 60 | constexpr auto cat_(kumi::_::adl_tag_t, T&& t, Seq inner, std::index_sequence<I...>) | |
| 16 | { | ||
| 17 | using outer = kumi::function::cat_index_sequence< | ||
| 18 | kumi::function::fill_index_sequence<I, kumi::size_v<kumi::element_t<I, T>>>...>; | ||
| 19 | 60 | return kumi::_::builder(KUMI_FWD(t), inner, outer{}); | |
| 20 | } | ||
| 21 | } | ||
| 22 | |||
| 23 | struct cat_t | ||
| 24 | { | ||
| 25 | template<kumi::concepts::product_type... Ts> | ||
| 26 | [[nodiscard]] KUMI_ABI constexpr auto operator()(Ts&&... ts) const | ||
| 27 | requires(kumi::concepts::follows_same_semantic<Ts...>) | ||
| 28 | { | ||
| 29 | if constexpr (sizeof...(Ts) == 0) return kumi::tuple{}; | ||
| 30 | else | ||
| 31 | { | ||
| 32 | using inner = kumi::function::cat_index_sequence<kumi::function::indexes_for<Ts>...>; | ||
| 33 | using outer = std::make_index_sequence<sizeof...(Ts)>; | ||
| 34 | 31 | return cat_(kumi::_::adl_tag, kumi::forward_as_tuple(KUMI_FWD(ts)...), inner{}, outer{}); | |
| 35 | } | ||
| 36 | } | ||
| 37 | }; | ||
| 38 | |||
| 39 | //==================================================================================================================== | ||
| 40 | /** | ||
| 41 | @ingroup kumi_generators | ||
| 42 | |||
| 43 | @var cat | ||
| 44 | @brief Callable object concatenating multiple product types into a single one | ||
| 45 | |||
| 46 | @note This function does not take part in overload resolution if the input product types do not follow the same | ||
| 47 | semantic. @see concepts::follows_same_semantic | ||
| 48 | |||
| 49 | @qualifier nodiscard | ||
| 50 | @qualifier inline | ||
| 51 | @qualifier constexpr | ||
| 52 | |||
| 53 | @groupheader{Header file} | ||
| 54 | @code | ||
| 55 | #include <kumi/algorithm/cat.hpp> | ||
| 56 | @endcode | ||
| 57 | |||
| 58 | @groupheader{Call Signature} | ||
| 59 | |||
| 60 | @code | ||
| 61 | template<product_type... Ts> | ||
| 62 | constexpr decltype(auto) cat(Ts&&... ts); | ||
| 63 | @endcode | ||
| 64 | |||
| 65 | @subgroupheader{Parameters} | ||
| 66 | - `ts`: Product types to concatenate | ||
| 67 | |||
| 68 | @subgroupheader{Return value} | ||
| 69 | - A product type made of all element of all input product types in order. | ||
| 70 | |||
| 71 | @groupheader{Helper type} | ||
| 72 | |||
| 73 | @snippet include/kumi/algorithm/cat.hpp cat_t | ||
| 74 | |||
| 75 | Computes the return type of a call to kumi::cat | ||
| 76 | |||
| 77 | @groupheader{Examples} | ||
| 78 | |||
| 79 | @tab_begin | ||
| 80 | |||
| 81 | @tab{Tuple} | ||
| 82 | @godbolt{doc/tuple/algo/cat.cpp} | ||
| 83 | |||
| 84 | @tab{Record} | ||
| 85 | @godbolt{doc/record/algo/cat.cpp} | ||
| 86 | |||
| 87 | @tab_end | ||
| 88 | **/ | ||
| 89 | //==================================================================================================================== | ||
| 90 | KUMI_VARIABLE_ABI constexpr cat_t cat{}; | ||
| 91 | |||
| 92 | namespace result | ||
| 93 | { | ||
| 94 | //! [cat_t] | ||
| 95 | template<concepts::product_type... Ts> using cat_t = decltype(kumi::cat(std::declval<Ts>()...)); | ||
| 96 | |||
| 97 | template<kumi::concepts::product_type... Ts> struct cat | ||
| 98 | { | ||
| 99 | using type = kumi::result::cat_t<Ts...>; | ||
| 100 | }; | ||
| 101 | |||
| 102 | //! [cat_t] | ||
| 103 | } | ||
| 104 | } | ||
| 105 |