[cfe-commits] [libcxx] r119560 - in /libcxx/trunk: include/ src/ test/strings/basic.string/string.modifiers/string_replace/

Howard Hinnant hhinnant at apple.com
Wed Nov 17 13:11:40 PST 2010


Author: hhinnant
Date: Wed Nov 17 15:11:40 2010
New Revision: 119560

URL: http://llvm.org/viewvc/llvm-project?rev=119560&view=rev
Log:
LWG 1323

Modified:
    libcxx/trunk/include/string
    libcxx/trunk/src/string.cpp
    libcxx/trunk/test/strings/basic.string/string.modifiers/string_replace/iter_iter_initializer_list.pass.cpp
    libcxx/trunk/test/strings/basic.string/string.modifiers/string_replace/iter_iter_iter_iter.pass.cpp
    libcxx/trunk/test/strings/basic.string/string.modifiers/string_replace/iter_iter_pointer.pass.cpp
    libcxx/trunk/test/strings/basic.string/string.modifiers/string_replace/iter_iter_pointer_size.pass.cpp
    libcxx/trunk/test/strings/basic.string/string.modifiers/string_replace/iter_iter_size_char.pass.cpp
    libcxx/trunk/test/strings/basic.string/string.modifiers/string_replace/iter_iter_string.pass.cpp

Modified: libcxx/trunk/include/string
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/string?rev=119560&r1=119559&r2=119560&view=diff
==============================================================================
--- libcxx/trunk/include/string (original)
+++ libcxx/trunk/include/string Wed Nov 17 15:11:40 2010
@@ -200,13 +200,13 @@
     basic_string& replace(size_type pos, size_type n1, const_pointer s, size_type n2);
     basic_string& replace(size_type pos, size_type n1, const_pointer s);
     basic_string& replace(size_type pos, size_type n1, size_type n2, value_type c);
-    basic_string& replace(iterator i1, iterator i2, const basic_string& str);
-    basic_string& replace(iterator i1, iterator i2, const_pointer s, size_type n);
-    basic_string& replace(iterator i1, iterator i2, const_pointer s);
-    basic_string& replace(iterator i1, iterator i2, size_type n, value_type c);
+    basic_string& replace(const_iterator i1, const_iterator i2, const basic_string& str);
+    basic_string& replace(const_iterator i1, const_iterator i2, const_pointer s, size_type n);
+    basic_string& replace(const_iterator i1, const_iterator i2, const_pointer s);
+    basic_string& replace(const_iterator i1, const_iterator i2, size_type n, value_type c);
     template<class InputIterator>
-        basic_string& replace(iterator i1, iterator i2, InputIterator j1, InputIterator j2);
-    basic_string& replace(iterator i1, iterator i2, initializer_list<value_type>);
+        basic_string& replace(const_iterator i1, const_iterator i2, InputIterator j1, InputIterator j2);
+    basic_string& replace(const_iterator i1, const_iterator i2, initializer_list<value_type>);
 
     size_type copy(pointer s, size_type n, size_type pos = 0) const;
     basic_string substr(size_type pos = 0, size_type n = npos) const;
@@ -1198,19 +1198,19 @@
     basic_string& replace(size_type __pos, size_type __n1, const_pointer __s, size_type __n2);
     basic_string& replace(size_type __pos, size_type __n1, const_pointer __s);
     basic_string& replace(size_type __pos, size_type __n1, size_type __n2, value_type __c);
-    basic_string& replace(iterator __i1, iterator __i2, const basic_string& __str);
-    basic_string& replace(iterator __i1, iterator __i2, const_pointer __s, size_type __n);
-    basic_string& replace(iterator __i1, iterator __i2, const_pointer __s);
-    basic_string& replace(iterator __i1, iterator __i2, size_type __n, value_type __c);
+    basic_string& replace(const_iterator __i1, const_iterator __i2, const basic_string& __str);
+    basic_string& replace(const_iterator __i1, const_iterator __i2, const_pointer __s, size_type __n);
+    basic_string& replace(const_iterator __i1, const_iterator __i2, const_pointer __s);
+    basic_string& replace(const_iterator __i1, const_iterator __i2, size_type __n, value_type __c);
     template<class _InputIterator>
         typename enable_if
         <
             __is_input_iterator<_InputIterator>::value,
             basic_string&
         >::type
-        replace(iterator __i1, iterator __i2, _InputIterator __j1, _InputIterator __j2);
+        replace(const_iterator __i1, const_iterator __i2, _InputIterator __j1, _InputIterator __j2);
     _LIBCPP_INLINE_VISIBILITY
-    basic_string& replace(iterator __i1, iterator __i2, initializer_list<value_type> __il)
+    basic_string& replace(const_iterator __i1, const_iterator __i2, initializer_list<value_type> __il)
         {return replace(__i1, __i2, __il.begin(), __il.end());}
 
     size_type copy(pointer __s, size_type __n, size_type __pos = 0) const;
@@ -2400,7 +2400,7 @@
     __is_input_iterator<_InputIterator>::value,
     basic_string<_CharT, _Traits, _Allocator>&
 >::type
-basic_string<_CharT, _Traits, _Allocator>::replace(iterator __i1, iterator __i2,
+basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_iterator __i2,
                                                    _InputIterator __j1, _InputIterator __j2)
 {
     for (; true; ++__i1, ++__j1)
@@ -2416,7 +2416,7 @@
             erase(__i1, __i2);
             break;
         }
-        traits_type::assign(*__i1, *__j1);
+        traits_type::assign(const_cast<value_type&>(*__i1), *__j1);
     }
     return *this;
 }
@@ -2453,7 +2453,7 @@
 template <class _CharT, class _Traits, class _Allocator>
 _LIBCPP_INLINE_VISIBILITY inline
 basic_string<_CharT, _Traits, _Allocator>&
-basic_string<_CharT, _Traits, _Allocator>::replace(iterator __i1, iterator __i2, const basic_string& __str)
+basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_iterator __i2, const basic_string& __str)
 {
     return replace(static_cast<size_type>(__i1 - begin()), static_cast<size_type>(__i2 - __i1),
                    __str.data(), __str.size());
@@ -2462,7 +2462,7 @@
 template <class _CharT, class _Traits, class _Allocator>
 _LIBCPP_INLINE_VISIBILITY inline
 basic_string<_CharT, _Traits, _Allocator>&
-basic_string<_CharT, _Traits, _Allocator>::replace(iterator __i1, iterator __i2, const_pointer __s, size_type __n)
+basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_iterator __i2, const_pointer __s, size_type __n)
 {
     return replace(static_cast<size_type>(__i1 - begin()), static_cast<size_type>(__i2 - __i1), __s, __n);
 }
@@ -2470,7 +2470,7 @@
 template <class _CharT, class _Traits, class _Allocator>
 _LIBCPP_INLINE_VISIBILITY inline
 basic_string<_CharT, _Traits, _Allocator>&
-basic_string<_CharT, _Traits, _Allocator>::replace(iterator __i1, iterator __i2, const_pointer __s)
+basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_iterator __i2, const_pointer __s)
 {
     return replace(static_cast<size_type>(__i1 - begin()), static_cast<size_type>(__i2 - __i1), __s);
 }
@@ -2478,7 +2478,7 @@
 template <class _CharT, class _Traits, class _Allocator>
 _LIBCPP_INLINE_VISIBILITY inline
 basic_string<_CharT, _Traits, _Allocator>&
-basic_string<_CharT, _Traits, _Allocator>::replace(iterator __i1, iterator __i2, size_type __n, value_type __c)
+basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_iterator __i2, size_type __n, value_type __c)
 {
     return replace(static_cast<size_type>(__i1 - begin()), static_cast<size_type>(__i2 - __i1), __n, __c);
 }
@@ -3719,12 +3719,12 @@
 extern template
     enable_if<__is_input_iterator<char const*>::value, string&>::type
     string::
-    replace<char const*>(string::iterator, string::iterator, char const*, char const*);
+    replace<char const*>(string::const_iterator, string::const_iterator, char const*, char const*);
 
 extern template
     enable_if<__is_input_iterator<wchar_t const*>::value, wstring&>::type
     wstring::
-    replace<wchar_t const*>(wstring::iterator, wstring::iterator, wchar_t const*, wchar_t const*);
+    replace<wchar_t const*>(wstring::const_iterator, wstring::const_iterator, wchar_t const*, wchar_t const*);
 
 extern template
     enable_if<__is_forward_iterator<wchar_t*>::value, wstring&>::type

Modified: libcxx/trunk/src/string.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/string.cpp?rev=119560&r1=119559&r2=119560&view=diff
==============================================================================
--- libcxx/trunk/src/string.cpp (original)
+++ libcxx/trunk/src/string.cpp Wed Nov 17 15:11:40 2010
@@ -54,12 +54,12 @@
 template
     enable_if<__is_input_iterator<char const*>::value, string&>::type
     string::
-    replace<char const*>(string::iterator, string::iterator, char const*, char const*);
+    replace<char const*>(string::const_iterator, string::const_iterator, char const*, char const*);
 
 template
     enable_if<__is_input_iterator<wchar_t const*>::value, wstring&>::type
     wstring::
-    replace<wchar_t const*>(wstring::iterator, wstring::iterator, wchar_t const*, wchar_t const*);
+    replace<wchar_t const*>(wstring::const_iterator, wstring::const_iterator, wchar_t const*, wchar_t const*);
 
 template
     enable_if<__is_forward_iterator<wchar_t*>::value, wstring&>::type

Modified: libcxx/trunk/test/strings/basic.string/string.modifiers/string_replace/iter_iter_initializer_list.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/strings/basic.string/string.modifiers/string_replace/iter_iter_initializer_list.pass.cpp?rev=119560&r1=119559&r2=119560&view=diff
==============================================================================
--- libcxx/trunk/test/strings/basic.string/string.modifiers/string_replace/iter_iter_initializer_list.pass.cpp (original)
+++ libcxx/trunk/test/strings/basic.string/string.modifiers/string_replace/iter_iter_initializer_list.pass.cpp Wed Nov 17 15:11:40 2010
@@ -9,7 +9,7 @@
 
 // <string>
 
-// basic_string& replace(iterator i1, iterator i2, initializer_list<charT> il);
+// basic_string& replace(const_iterator i1, const_iterator i2, initializer_list<charT> il);
 
 #include <string>
 #include <cassert>
@@ -19,7 +19,7 @@
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
     {
         std::string s("123def456");
-        s.replace(s.begin() + 3, s.begin() + 6, {'a', 'b', 'c'});
+        s.replace(s.cbegin() + 3, s.cbegin() + 6, {'a', 'b', 'c'});
         assert(s == "123abc456");
     }
 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES

Modified: libcxx/trunk/test/strings/basic.string/string.modifiers/string_replace/iter_iter_iter_iter.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/strings/basic.string/string.modifiers/string_replace/iter_iter_iter_iter.pass.cpp?rev=119560&r1=119559&r2=119560&view=diff
==============================================================================
--- libcxx/trunk/test/strings/basic.string/string.modifiers/string_replace/iter_iter_iter_iter.pass.cpp (original)
+++ libcxx/trunk/test/strings/basic.string/string.modifiers/string_replace/iter_iter_iter_iter.pass.cpp Wed Nov 17 15:11:40 2010
@@ -11,7 +11,7 @@
 
 // template<class InputIterator>
 //   basic_string&
-//   replace(iterator i1, iterator i2, InputIterator j1, InputIterator j2);
+//   replace(const_iterator i1, const_iterator i2, InputIterator j1, InputIterator j2);
 
 #include <string>
 #include <iterator>
@@ -24,8 +24,8 @@
 test(S s, typename S::size_type pos1, typename S::size_type n1, It f, It l, S expected)
 {
     typename S::size_type old_size = s.size();
-    typename S::iterator first = s.begin() + pos1;
-    typename S::iterator last = s.begin() + pos1 + n1;
+    typename S::const_iterator first = s.begin() + pos1;
+    typename S::const_iterator last = s.begin() + pos1 + n1;
     s.replace(first, last, f, l);
     assert(s.__invariants());
     assert(s == expected);

Modified: libcxx/trunk/test/strings/basic.string/string.modifiers/string_replace/iter_iter_pointer.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/strings/basic.string/string.modifiers/string_replace/iter_iter_pointer.pass.cpp?rev=119560&r1=119559&r2=119560&view=diff
==============================================================================
--- libcxx/trunk/test/strings/basic.string/string.modifiers/string_replace/iter_iter_pointer.pass.cpp (original)
+++ libcxx/trunk/test/strings/basic.string/string.modifiers/string_replace/iter_iter_pointer.pass.cpp Wed Nov 17 15:11:40 2010
@@ -10,7 +10,7 @@
 // <string>
 
 // basic_string<charT,traits,Allocator>&
-//   replace(iterator i1, iterator i2, const charT* s);
+//   replace(const_iterator i1, const_iterator i2, const charT* s);
 
 #include <stdio.h>
 
@@ -24,8 +24,8 @@
 test(S s, S::size_type pos1, S::size_type n1, const S::value_type* str, S expected)
 {
     S::size_type old_size = s.size();
-    S::iterator first = s.begin() + pos1;
-    S::iterator last = s.begin() + pos1 + n1;
+    S::const_iterator first = s.begin() + pos1;
+    S::const_iterator last = s.begin() + pos1 + n1;
     s.replace(first, last, str);
     assert(s.__invariants());
     assert(s == expected);

Modified: libcxx/trunk/test/strings/basic.string/string.modifiers/string_replace/iter_iter_pointer_size.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/strings/basic.string/string.modifiers/string_replace/iter_iter_pointer_size.pass.cpp?rev=119560&r1=119559&r2=119560&view=diff
==============================================================================
--- libcxx/trunk/test/strings/basic.string/string.modifiers/string_replace/iter_iter_pointer_size.pass.cpp (original)
+++ libcxx/trunk/test/strings/basic.string/string.modifiers/string_replace/iter_iter_pointer_size.pass.cpp Wed Nov 17 15:11:40 2010
@@ -10,7 +10,7 @@
 // <string>
 
 // basic_string<charT,traits,Allocator>&
-//   replace(iterator i1, iterator i2, const charT* s, size_type n);
+//   replace(const_iterator i1, const_iterator i2, const charT* s, size_type n);
 
 #include <stdio.h>
 
@@ -25,8 +25,8 @@
      S::size_type n2, S expected)
 {
     S::size_type old_size = s.size();
-    S::iterator first = s.begin() + pos1;
-    S::iterator last = s.begin() + pos1 + n1;
+    S::const_iterator first = s.begin() + pos1;
+    S::const_iterator last = s.begin() + pos1 + n1;
     s.replace(first, last, str, n2);
     assert(s.__invariants());
     assert(s == expected);

Modified: libcxx/trunk/test/strings/basic.string/string.modifiers/string_replace/iter_iter_size_char.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/strings/basic.string/string.modifiers/string_replace/iter_iter_size_char.pass.cpp?rev=119560&r1=119559&r2=119560&view=diff
==============================================================================
--- libcxx/trunk/test/strings/basic.string/string.modifiers/string_replace/iter_iter_size_char.pass.cpp (original)
+++ libcxx/trunk/test/strings/basic.string/string.modifiers/string_replace/iter_iter_size_char.pass.cpp Wed Nov 17 15:11:40 2010
@@ -10,7 +10,7 @@
 // <string>
 
 // basic_string<charT,traits,Allocator>&
-//   replace(iterator i1, iterator i2, size_type n, charT c);
+//   replace(const_iterator i1, const_iterator i2, size_type n, charT c);
 
 #include <stdio.h>
 
@@ -25,8 +25,8 @@
      S::value_type c, S expected)
 {
     S::size_type old_size = s.size();
-    S::iterator first = s.begin() + pos1;
-    S::iterator last = s.begin() + pos1 + n1;
+    S::const_iterator first = s.begin() + pos1;
+    S::const_iterator last = s.begin() + pos1 + n1;
     s.replace(first, last, n2, c);
     assert(s.__invariants());
     assert(s == expected);

Modified: libcxx/trunk/test/strings/basic.string/string.modifiers/string_replace/iter_iter_string.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/strings/basic.string/string.modifiers/string_replace/iter_iter_string.pass.cpp?rev=119560&r1=119559&r2=119560&view=diff
==============================================================================
--- libcxx/trunk/test/strings/basic.string/string.modifiers/string_replace/iter_iter_string.pass.cpp (original)
+++ libcxx/trunk/test/strings/basic.string/string.modifiers/string_replace/iter_iter_string.pass.cpp Wed Nov 17 15:11:40 2010
@@ -10,7 +10,7 @@
 // <string>
 
 // basic_string<charT,traits,Allocator>&
-//   replace(iterator i1, iterator i2, const basic_string& str);
+//   replace(const_iterator i1, const_iterator i2, const basic_string& str);
 
 #include <stdio.h>
 
@@ -24,8 +24,8 @@
 test(S s, S::size_type pos1, S::size_type n1, S str, S expected)
 {
     S::size_type old_size = s.size();
-    S::iterator first = s.begin() + pos1;
-    S::iterator last = s.begin() + pos1 + n1;
+    S::const_iterator first = s.begin() + pos1;
+    S::const_iterator last = s.begin() + pos1 + n1;
     s.replace(first, last, str);
     assert(s.__invariants());
     assert(s == expected);





More information about the cfe-commits mailing list