Title
Incorrect OutputIterator concept requirements for replace algorithms
Status
nad concepts
Section
[alg.replace]
Submitter
Howard Hinnant

Created on 2009-03-22.00:00:00 last changed 164 months ago

Messages

Date: 2010-10-21.18:28:33

Proposed resolution:

Change in [algorithms.syn] and [alg.replace]:

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);
Date: 2010-10-21.18:28:33

[ Summit: ]

We agree. To be handled by Howard.

Date: 2012-10-21.13:19:07

Addresses UK 301 [CD1]

replace and replace_if have the requirement: OutputIterator<Iter, Iter::reference> Which implies they need to copy some values in the range the algorithm is iterating over. This is not however the case, the only thing that happens is const T&s might be copied over existing elements (hence the OutputIterator<Iter, const T&>.

Remove OutputIterator<Iter, Iter::reference> from replace and replace_if.

History
Date User Action Args
2010-10-21 18:28:33adminsetmessages: + msg648
2010-10-21 18:28:33adminsetmessages: + msg647
2009-03-22 00:00:00admincreate