Created on 2025-11-04.00:00:00 last changed 1 month ago
Proposed resolution:
This wording is relative to N5014.
Modify [algorithm.syn], header <algorithm> synopsis, as indicated:
[…]
namespace ranges {
template<input_iterator I, sentinel_for<I> S, class Proj = identity,
class T1 = projected_value_t<I, Proj>, class T2 = T1iter_value_t<I>>
requires indirectly_writable<I, const T2&> &&
indirect_binary_predicate<ranges::equal_to, projected<I, Proj>, const T1*>
constexpr I
replace(I first, S last, const T1& old_value, const T2& new_value, Proj proj = {});
template<input_range R, class Proj = identity,
class T1 = projected_value_t<iterator_t<R>, Proj>, class T2 = T1range_value_t<R>>
requires indirectly_writable<iterator_t<R>, const T2&> &&
indirect_binary_predicate<ranges::equal_to,
projected<iterator_t<R>, Proj>, const T1*>
constexpr borrowed_iterator_t<R>
replace(R&& r, const T1& old_value, const T2& new_value, Proj proj = {});
template<execution-policy Ep, random_access_iterator I, sized_sentinel_for<I> S,
class Proj = identity, class T1 = projected_value_t<I, Proj>, class T2 = T1iter_value_t<I>>
requires indirectly_writable<I, const T2&> &&
indirect_binary_predicate<ranges::equal_to, projected<I, Proj>, const T1*>
I replace(Ep&& exec, I first, S last,
const T1& old_value, const T2& new_value, Proj proj = {}); // freestanding-deleted
template<execution-policy Ep, sized-random-access-range R, class Proj = identity,
class T1 = projected_value_t<iterator_t<R>, Proj>, class T2 = T1range_value_t<R>>
requires indirectly_writable<iterator_t<R>, const T2&> &&
indirect_binary_predicate<ranges::equal_to,
projected<iterator_t<R>, Proj>, const T1*>
borrowed_iterator_t<R>
replace(Ep&& exec, R&& r, const T1& old_value, const T2& new_value,
Proj proj = {}); // freestanding-deleted
template<input_iterator I, sentinel_for<I> S, class Proj = identity,
class T = projectediter_value_t<I, Proj>,
indirect_unary_predicate<projected<I, Proj>> Pred>
requires indirectly_writable<I, const T&>
constexpr I replace_if(I first, S last, Pred pred, const T& new_value, Proj proj = {});
template<input_range R, class Proj = identity, class T = projected_value_t<Irange_value_t<R, Proj>,
indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
requires indirectly_writable<iterator_t<R>, const T&>
constexpr borrowed_iterator_t<R>
replace_if(R&& r, Pred pred, const T& new_value, Proj proj = {});
template<execution-policy Ep, random_access_iterator I, sized_sentinel_for<I> S,
class Proj = identity, class T = projectediter_value_t<I, Proj>,
indirect_unary_predicate<projected<I, Proj>> Pred>
requires indirectly_writable<I, const T&>
I replace_if(Ep&& exec, I first, S last, Pred pred,
const T& new_value, Proj proj = {}); // freestanding-deleted
template<execution-policy Ep, sized-random-access-range R, class Proj = identity,
class T = projected_value_t<iterator_t<R>range_value_t<R, Proj>,
indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
requires indirectly_writable<iterator_t<R>, const T&>
borrowed_iterator_t<R>
replace_if(Ep&& exec, R&& r, Pred pred, const T& new_value,
Proj proj = {}); // freestanding-deleted
}
[…]
Modify [alg.replace] as indicated:
[…] template<input_iterator I, sentinel_for<I> S, class Proj = identity, class T1 = projected_value_t<I, Proj>, class T2 =T1iter_value_t<I>> requires indirectly_writable<I, const T2&> && indirect_binary_predicate<ranges::equal_to, projected<I, Proj>, const T1*> constexpr I ranges::replace(I first, S last, const T1& old_value, const T2& new_value, Proj proj = {}); template<input_range R, class Proj = identity, class T1 = projected_value_t<iterator_t<R>, Proj>, class T2 =T1range_value_t<R>> requires indirectly_writable<iterator_t<R>, const T2&> && indirect_binary_predicate<ranges::equal_to, projected<iterator_t<R>, Proj>, const T1*> constexpr borrowed_iterator_t<R> ranges::replace(R&& r, const T1& old_value, const T2& new_value, Proj proj = {}); template<execution-policy Ep, random_access_iterator I, sized_sentinel_for<I> S, class Proj = identity, class T1 = projected_value_t<I, Proj>, class T2 =T1iter_value_t<I>> requires indirectly_writable<I, const T2&> && indirect_binary_predicate<ranges::equal_to, projected<I, Proj>, const T1*> I ranges::replace(Ep&& exec, I first, S last, const T1& old_value, const T2& new_value, Proj proj = {}); template<execution-policy Ep, sized-random-access-range R, class Proj = identity, class T1 = projected_value_t<iterator_t<R>, Proj>, class T2 =T1range_value_t<R>> requires indirectly_writable<iterator_t<R>, const T2&> && indirect_binary_predicate<ranges::equal_to, projected<iterator_t<R>, Proj>, const T1*> borrowed_iterator_t<R> ranges::replace(Ep&& exec, R&& r, const T1& old_value, const T2& new_value, Proj proj = {}); template<input_iterator I, sentinel_for<I> S, class Proj = identity, class T =projectediter_value_t<I, Proj>, indirect_unary_predicate<projected<I, Proj>> Pred> requires indirectly_writable<I, const T&> constexpr I ranges::replace_if(I first, S last, Pred pred, const T& new_value, Proj proj = {}); template<input_range R, class Proj = identity, class T =projected_value_t<Irange_value_t<R, Proj>, indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred> requires indirectly_writable<iterator_t<R>, const T&> constexpr borrowed_iterator_t<R> ranges::replace_if(R&& r, Pred pred, const T& new_value, Proj proj = {}); template<execution-policy Ep, random_access_iterator I, sized_sentinel_for<I> S, class Proj = identity, class T =projectediter_value_t<I, Proj>, indirect_unary_predicate<projected<I, Proj>> Pred> requires indirectly_writable<I, const T&> I ranges::replace_if(Ep&& exec, I first, S last, Pred pred, const T& new_value, Proj proj = {}); template<execution-policy Ep, sized-random-access-range R, class Proj = identity, class T =projected_value_t<iterator_t<R>range_value_t<R, Proj>, indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred> requires indirectly_writable<iterator_t<R>, const T&> borrowed_iterator_t<R> ranges::replace_if(Ep&& exec, R&& r, Pred pred, const T& new_value, Proj proj = {});-1- […]
[ Kona 2025-11-08; Status changed: Immediate → WP. ]
[ Kona 2025-11-04; approved by LWG. Status changed: New → Immediate. ]
The default template argument for the type of the new value in `ranges::replace` and `ranges::replace_if` should not have projections applied.
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2025-11-11 10:48:55 | admin | set | messages: + msg15697 |
| 2025-11-11 10:48:55 | admin | set | status: immediate -> wp |
| 2025-11-04 23:50:08 | admin | set | messages: + msg15507 |
| 2025-11-04 23:50:08 | admin | set | status: new -> immediate |
| 2025-11-04 23:10:27 | admin | set | messages: + msg15504 |
| 2025-11-04 00:00:00 | admin | create | |