14 #ifndef RANGES_V3_VIEW_REPLACE_HPP
15 #define RANGES_V3_VIEW_REPLACE_HPP
17 #include <type_traits>
27 #include <range/v3/utility/static_const.hpp>
32 #include <range/v3/detail/prologue.hpp>
39 template<
typename Val1,
typename Val2>
47 replacer_fn() =
default;
48 constexpr replacer_fn(Val1 old_value, Val2 new_value)
49 : old_value_(std::move(old_value))
50 , new_value_(std::move(new_value))
54 [[noreturn]] common_type_t<decay_t<unwrap_reference_t<Val2 const &>>,
56 operator()(copy_tag, I
const &)
const
62 common_reference_t<unwrap_reference_t<Val2 const &>, iter_reference_t<I>>
63 operator()(I
const & i)
const
66 if(x == unwrap_reference(old_value_))
67 return unwrap_reference(new_value_);
68 return ((decltype(x) &&)x);
72 common_reference_t<unwrap_reference_t<Val2 const &>,
73 iter_rvalue_reference_t<I>>
74 operator()(move_tag, I
const & i)
const
76 auto && x = iter_move(i);
77 if(x == unwrap_reference(old_value_))
78 return unwrap_reference(new_value_);
79 return ((decltype(x) &&)x);
91 template(
typename Rng,
typename Val1,
typename Val2)(
92 requires viewable_range<Rng> AND input_range<Rng> AND
96 equality_comparable_with<
98 range_value_t<Rng>> AND
100 range_value_t<Rng>> AND
102 range_reference_t<Rng>> AND
103 common_reference_with<
105 range_rvalue_reference_t<Rng>>)
108 detail::decay_t<Val1>,
109 detail::decay_t<Val2>>
110 operator()(Rng && rng, Val1 && old_value,
111 Val2 && new_value)
const
114 all(
static_cast<Rng &&
>(rng)),
115 {
static_cast<Val1 &&
>(old_value),
static_cast<Val2 &&
>(new_value)}};
121 using replace_base_fn::operator();
123 template(
typename Val1,
typename Val2)(
126 constexpr
auto operator()(Val1 old_value, Val2 new_value)
const
140 #include <range/v3/detail/epilogue.hpp>
decltype(unwrap_reference(std::declval< T >())) unwrap_reference_t
Definition: reference_wrapper.hpp:178
RANGES_INLINE_VARIABLE(detail::to_container_fn< detail::from_range< std::vector >>, to_vector) template< template< typename... > class ContT > auto to(RANGES_HIDDEN_DETAIL(detail
For initializing a container of the specified type with the elements of an Range.
Definition: conversion.hpp:399
defer< bind_back, Fn, Ts... > bind_back
Definition: meta.hpp:994
Definition: replace.hpp:90
Definition: replace.hpp:120