This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of NAD Concepts status.

### 913. Superfluous requirements for replace algorithms

Section: 27.7.5 [alg.replace] Status: NAD Concepts Submitter: Daniel Krügler Opened: 2008-10-03 Last modified: 2016-01-28

Priority: Not Prioritized

View all other issues in [alg.replace].

View all issues with NAD Concepts status.

Discussion:

(A) 27.7.5 [alg.replace]/1:

> Requires: The expression `*first = new_value` shall be valid.

(B) 27.7.5 [alg.replace]/4:

> Requires: The results of the expressions `*first` and `new_value` shall be writable to the result output iterator.[..]

Since conceptualization, the quoted content of these clauses is covered by the existing requirements

(A) `OutputIterator<Iter, const T&>`

and

(B) `OutputIterator<OutIter, InIter::reference> && OutputIterator<OutIter, const T&>`

resp, and thus should be removed.

[ Batavia (2009-05): ]

> We agree with the proposed resolution.

> Move to Tentatively Ready.

Proposed resolution:

1. Remove 27.7.5 [alg.replace]/1.

   >     template<ForwardIterator Iter, class T>
   >       requires OutputIterator<Iter, Iter::reference>
   >             && OutputIterator<Iter, const T&>
   >             && HasEqualTo<Iter::value_type, T>
   >       void replace(Iter first, Iter last,
   >                    const T& old_value, const T& new_value);

   >     template<ForwardIterator Iter, Predicate<auto, Iter::value_type> Pred, class T>
   >       requires OutputIterator<Iter, Iter::reference>
   >             && OutputIterator<Iter, const T&>
   >             && CopyConstructible<Pred>
   >       void replace_if(Iter first, Iter last,
   >                       Pred pred, const T& new_value);

   > > 1 Requires: The expression `*first = new_value` shall be valid.

2. 27.7.5 [alg.replace]/4: Remove the sentence "The results of the expressions `*first` and `new_value` shall be writable to the result output iterator.".

   >     template<InputIterator InIter, typename OutIter, class T>
   >       requires OutputIterator<OutIter, InIter::reference>
   >             && OutputIterator<OutIter, const T&>
   >             && HasEqualTo<InIter::value_type, T>
   >       OutIter replace_copy(InIter first, InIter last,
   >                            OutIter result,
   >                            const T& old_value, const T& new_value);

   >     template<InputIterator InIter, typename OutIter,
   >              Predicate<auto, InIter::value_type> Pred, class T>
   >       requires OutputIterator<OutIter, InIter::reference>
   >             && OutputIterator<OutIter, const T&>
   >             && CopyConstructible<Pred>
   >       OutIter replace_copy_if(InIter first, InIter last,
   >                               OutIter result,
   >                               Pred pred, const T& new_value);

   > > 4 Requires: The results of the expressions `*first` and `new_value` shall be writable to the `result` output iterator. The ranges `[first,last)` and `[result,result + (last - first))` shall not overlap.