14#ifndef RANGES_V3_VIEW_REPLACE_IF_HPP
15#define RANGES_V3_VIEW_REPLACE_IF_HPP
30#include <range/v3/utility/static_const.hpp>
35#include <range/v3/detail/prologue.hpp>
42 template<
typename Pred,
typename Val>
43 struct replacer_if_fn : compressed_pair<semiregular_box_t<Pred>, Val>
46 using base_t = compressed_pair<semiregular_box_t<Pred>, Val>;
51 replacer_if_fn() =
default;
52 constexpr replacer_if_fn(Pred pred, Val new_value)
53 : base_t{std::move(pred), std::move(new_value)}
57 [[noreturn]] common_type_t<decay_t<unwrap_reference_t<Val const &>>,
59 operator()(copy_tag, I
const &)
const
65 requires (!invocable<Pred
const &, iter_reference_t<I>>))
66 common_reference_t<unwrap_reference_t<Val const &>, iter_reference_t<I>>
67 operator()(I
const & i)
71 return unwrap_reference(
second());
72 return (
decltype(x) &&)x;
75 requires invocable<Pred
const &, iter_reference_t<I>>)
76 common_reference_t<unwrap_reference_t<Val const &>, iter_reference_t<I>>
77 operator()(I
const & i)
const
81 return unwrap_reference(
second());
82 return (
decltype(x) &&)x;
86 requires (!invocable<Pred
const &, iter_rvalue_reference_t<I>>))
88 unwrap_reference_t<Val const &>,
89 iter_rvalue_reference_t<I>>
90 operator()(move_tag, I
const & i)
92 auto && x = iter_move(i);
94 return unwrap_reference(
second());
95 return (
decltype(x) &&)x;
98 requires invocable<Pred
const &, iter_rvalue_reference_t<I>>)
100 unwrap_reference_t<Val const &>,
101 iter_rvalue_reference_t<I>>
102 operator()(move_tag, I
const & i)
const
104 auto && x = iter_move(i);
106 return unwrap_reference(
second());
107 return (
decltype(x) &&)x;
119 template(
typename Rng,
typename Pred,
typename Val)(
123 range_value_t<Rng>> AND
125 range_reference_t<Rng>> AND
127 range_rvalue_reference_t<Rng>>)
129 operator()(Rng && rng, Pred pred, Val new_value)
const
131 return {all(
static_cast<Rng &&
>(rng)),
132 {std::move(pred), std::move(new_value)}};
138 using replace_if_base_fn::operator();
140 template<
typename Pred,
typename Val>
141 constexpr auto operator()(Pred pred, Val new_value)
const
143 return make_view_closure(bind_back(
155#include <range/v3/detail/epilogue.hpp>
The indirect_unary_predicate concept.
The viewable_range concept.
decltype(unwrap_reference(std::declval< T >())) unwrap_reference_t
Definition reference_wrapper.hpp:178
decltype(begin(declval(Rng &))) iterator_t
Definition access.hpp:698
typename Fn::template invoke< Args... > invoke
Evaluate the invocable Fn with the arguments Args.
Definition meta.hpp:541
front< Pair > first
Retrieve the first element of the pair Pair.
Definition meta.hpp:2251
front< pop_front< Pair > > second
Retrieve the first element of the pair Pair.
Definition meta.hpp:2256
Definition replace_if.hpp:118
Definition replace_if.hpp:137