Warning, file /include/range/v3/functional/compose.hpp was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #ifndef RANGES_V3_FUNCTIONAL_COMPOSE_HPP
0014 #define RANGES_V3_FUNCTIONAL_COMPOSE_HPP
0015
0016 #include <type_traits>
0017 #include <utility>
0018
0019 #include <concepts/concepts.hpp>
0020
0021 #include <range/v3/detail/config.hpp>
0022 #include <range/v3/functional/invoke.hpp>
0023 #include <range/v3/utility/static_const.hpp>
0024
0025 #include <range/v3/detail/prologue.hpp>
0026
0027 namespace ranges
0028 {
0029
0030
0031 template<typename Second, typename First>
0032 struct composed
0033 {
0034 private:
0035 RANGES_NO_UNIQUE_ADDRESS
0036 First first_;
0037 RANGES_NO_UNIQUE_ADDRESS
0038 Second second_;
0039
0040
0041 template<typename A, typename B, typename... Ts>
0042 static constexpr auto
0043 CPP_auto_fun(do_)(A &&a, B &&b, std::false_type, Ts &&... ts)
0044 (
0045 return invoke((B &&) b, invoke((A &&) a, (Ts &&) ts...))
0046 )
0047 template<typename A, typename B, typename... Ts>
0048 static constexpr auto CPP_auto_fun(do_)(A &&a, B &&b, std::true_type, Ts &&... ts)
0049 (
0050 return (invoke((A &&) a, (Ts &&) ts...), invoke((B &&) b))
0051 )
0052 public:
0053 composed() = default;
0054
0055 constexpr composed(Second second, First first)
0056 : first_(std::move(first))
0057 , second_(std::move(second))
0058 {}
0059
0060 template<typename... Ts>
0061 constexpr auto CPP_auto_fun(operator())(Ts &&... ts)(mutable &)
0062 (
0063 return composed::do_(first_,
0064 second_,
0065 std::is_void<invoke_result_t<First &, Ts...>>{},
0066 (Ts &&) ts...)
0067 )
0068 template<typename... Ts>
0069 constexpr auto CPP_auto_fun(operator())(Ts &&... ts)(const &)
0070 (
0071 return composed::do_((First const &)first_,
0072 (Second const &)second_,
0073 std::is_void<invoke_result_t<First const &, Ts...>>{},
0074 (Ts &&) ts...)
0075 )
0076 template<typename... Ts>
0077 constexpr auto CPP_auto_fun(operator())(Ts &&... ts)(mutable &&)
0078 (
0079 return composed::do_((First &&)first_,
0080 (Second &&)second_,
0081 std::is_void<invoke_result_t<First &&, Ts...>>{},
0082 (Ts &&) ts...)
0083 )
0084
0085 };
0086
0087 struct compose_fn
0088 {
0089 template<typename Second, typename First>
0090 constexpr composed<Second, First> operator()(Second second, First first) const
0091 {
0092 return {std::move(second), std::move(first)};
0093 }
0094 };
0095
0096
0097
0098 RANGES_INLINE_VARIABLE(compose_fn, compose)
0099
0100 }
0101
0102 #include <range/v3/detail/epilogue.hpp>
0103
0104 #endif