Title
basic_string::replace should use const_iterator
Status
c++11
Section
[string.replace]
Submitter
Daniel Krügler

Created on 2010-02-19.00:00:00 last changed 161 months ago

Messages

Date: 2010-11-24.14:01:03

Proposed resolution:

  1. In [basic.string], class template basic_string synopsis change as indicated:

    // 21.4.6 modifiers:
    ...
    basic_string& replace(const_iterator i1, const_iterator i2,
                          const basic_string& str);
    basic_string& replace(const_iterator i1, const_iterator i2,
                          const charT* s, size_type n);
    basic_string& replace(const_iterator i1, const_iterator i2,
                          const charT* s);
    basic_string& replace(const_iterator i1, const_iterator i2,
                          size_type n, charT c);
    template<class InputIterator>
      basic_string& replace(const_iterator i1, const_iterator i2,
                            InputIterator j1, InputIterator j2);
    basic_string& replace(const_iterator, const_iterator,
                          initializer_list<charT>);
    
  2. In [string.replace] before p.18, change the following signatures as indicated:

    basic_string& replace(const_iterator i1, const_iterator i2, const basic_string& str);
    
  3. In [string.replace] before p.21, change the following signatures as indicated:

    basic_string&
      replace(const_iterator i1, const_iterator i2, const charT* s, size_type n);
    
  4. In [string.replace] before p.24, change the following signatures as indicated:

    basic_string& replace(const_iterator i1, const_iterator i2, const charT* s);
    
  5. In [string.replace] before p.27, change the following signatures as indicated:

    basic_string& replace(const_iterator i1, const_iterator i2, size_type n,
                          charT c);
    
  6. In [string.replace] before p.30, change the following signatures as indicated:

    template<class InputIterator>
      basic_string& replace(const_iterator i1, const_iterator i2,
                            InputIterator j1, InputIterator j2);
    
  7. In [string.replace] before p.33, change the following signatures as indicated:

    basic_string& replace(const_iterator i1, const_iterator i2,
                          initializer_list<charT> il);
    
Date: 2010-11-24.14:01:03

[ Adopted at 2010-11 Batavia ]

Date: 2010-10-21.19:06:53

[ Post-Rapperswil: ]

Moved to Tentatively Ready after 5 positive votes on c++std-lib.

Date: 2010-02-19.00:00:00

In contrast to all library usages of purely positional iterator values several overloads of std::basic_string::replace still use iterator instead of const_iterator arguments. The paper N3021 quite nicely visualizes the purely positional responsibilities of the function arguments.

This should be fixed to make the library consistent, the proposed changes are quite mechanic.

History
Date User Action Args
2011-08-23 20:07:26adminsetstatus: wp -> c++11
2010-11-24 14:01:03adminsetmessages: + msg5423
2010-11-14 13:10:57adminsetstatus: voting -> wp
2010-11-08 14:14:39adminsetstatus: ready -> voting
2010-10-21 19:06:53adminsetmessages: + msg4770
2010-10-21 19:06:53adminsetstatus: new -> ready
2010-10-21 18:28:33adminsetmessages: + msg1598
2010-02-19 00:00:00admincreate