Iros
 
Loading...
Searching...
No Matches
replace_if.h
Go to the documentation of this file.
1#pragma once
2
6
7namespace di::container {
8namespace detail {
10 template<concepts::InputIterator It, concepts::SentinelFor<It> Sent, typename U,
11 typename Proj = function::Identity, concepts::IndirectUnaryPredicate<meta::Projected<It, Proj>> Pred>
13 constexpr auto operator()(It first, Sent last, Pred pred, U const& new_value, Proj proj = {}) const -> It {
14 for (; first != last; ++first) {
15 if (function::invoke(pred, function::invoke(proj, *first))) {
16 *first = new_value;
17 }
18 }
19 return first;
20 }
21
22 template<concepts::InputContainer Con, typename U, typename Proj = function::Identity,
23 concepts::IndirectUnaryPredicate<meta::Projected<meta::ContainerIterator<Con>, Proj>> Pred>
24 requires(concepts::IndirectlyWritable<meta::ContainerIterator<Con>, U const&>)
25 constexpr auto operator()(Con&& container, Pred pred, U const& new_value, Proj proj = {}) const
27 return (*this)(container::begin(container), container::end(container), util::ref(pred), new_value, proj);
28 }
29 };
30}
31
32constexpr inline auto replace_if = detail::ReplaceIfFunction {};
33}
34
35namespace di {
37}
Definition indirectly_writable.h:8
Definition sequence.h:13
Definition sequence.h:12
constexpr auto replace_if
Definition replace_if.h:32
constexpr auto end
Definition end.h:47
constexpr auto begin
Definition begin.h:44
constexpr auto invoke
Definition invoke.h:100
Conditional< concepts::BorrowedContainer< Con >, ContainerIterator< Con >, container::Dangling > BorrowedIterator
Definition borrowed_iterator.h:11
constexpr auto ref
Definition reference_wrapper.h:98
Definition zstring_parser.h:9
constexpr auto proj
Definition proj.h:59