| 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 | struct reverse_t | ||
| 13 | { | ||
| 14 | template<kumi::concepts::product_type T> [[nodiscard]] KUMI_ABI constexpr auto operator()(T&& t) const | ||
| 15 | { | ||
| 16 | 4 | if constexpr (kumi::concepts::empty_product_type<T>) return builder<T>::make(); | |
| 17 | 7 | else return kumi::_::builder(KUMI_FWD(t), kumi::function::reverse_index_sequence<kumi::size_v<T>>{}); | |
| 18 | } | ||
| 19 | }; | ||
| 20 | |||
| 21 | //==================================================================================================================== | ||
| 22 | /** | ||
| 23 | @ingroup kumi_generators | ||
| 24 | |||
| 25 | @var reverse | ||
| 26 | @brief Callable object reversing elements of a product type | ||
| 27 | |||
| 28 | On record types, this function operates on elements as if they were ordered. The considered order is the order | ||
| 29 | of declaration. | ||
| 30 | |||
| 31 | @qualifier nodiscard | ||
| 32 | @qualifier inline | ||
| 33 | @qualifier constexpr | ||
| 34 | |||
| 35 | @groupheader{Header file} | ||
| 36 | @code | ||
| 37 | #include <kumi/algorithm/reverse.hpp> | ||
| 38 | @endcode | ||
| 39 | |||
| 40 | @groupheader{Call Signature} | ||
| 41 | |||
| 42 | @code | ||
| 43 | template<product_type T> | ||
| 44 | constexpr auto reverse(T && t) noexcept; | ||
| 45 | @endcode | ||
| 46 | |||
| 47 | @subgroupheader{Parameters} | ||
| 48 | |||
| 49 | - `t`: Product Type to reverse | ||
| 50 | |||
| 51 | @subgroupheader{Return value} | ||
| 52 | |||
| 53 | - A product type with the type of `t` and elements equal to (get<index<size_v<T> - 1 - Idx>>(t)...); | ||
| 54 | |||
| 55 | @groupheader{Helper type} | ||
| 56 | |||
| 57 | @snippet include/kumi/algorithm/reverse.hpp reverse_t | ||
| 58 | |||
| 59 | Computes the return type of a call to kumi::reverse | ||
| 60 | |||
| 61 | @groupheader{Examples} | ||
| 62 | |||
| 63 | @tab_begin | ||
| 64 | |||
| 65 | @tab{Tuple} | ||
| 66 | @godbolt{doc/tuple/algo/reverse.cpp} | ||
| 67 | |||
| 68 | @tab{Record} | ||
| 69 | @godbolt{doc/record/algo/reverse.cpp} | ||
| 70 | |||
| 71 | @tab_end | ||
| 72 | **/ | ||
| 73 | //==================================================================================================================== | ||
| 74 | KUMI_VARIABLE_ABI constexpr reverse_t reverse{}; | ||
| 75 | |||
| 76 | namespace result | ||
| 77 | { | ||
| 78 | //! [reverse_t] | ||
| 79 | template<kumi::concepts::product_type T> using reverse_t = decltype(kumi::reverse(std::declval<T>())); | ||
| 80 | |||
| 81 | template<kumi::concepts::product_type T> struct reverse | ||
| 82 | { | ||
| 83 | using type = kumi::result::reverse_t<T>; | ||
| 84 | }; | ||
| 85 | |||
| 86 | //! [reverse_t] | ||
| 87 | } | ||
| 88 | } | ||
| 89 |