2018-08-23 Jonathan Wakely <jwakely@redhat.com>
+ * include/bits/basic_string.h [_GLIBCXX_USE_CXX11_ABI]
+ (basic_string::__const_iterator): Change access to protected.
+ [!_GLIBCXX_USE_CXX11_ABI] (basic_string::__const_iterator): Define
+ as typedef for iterator.
+ * include/debug/string (__const_iterator): Use typedef from base.
+ (insert(const_iterator, _CharT))
+ (replace(const_iterator, const_iterator, const basic_string&))
+ (replace(const_iterator, const_iterator, const _CharT*, size_type))
+ (replace(const_iterator, const_iterator, const CharT*))
+ (replace(const_iterator, const_iterator, size_type, _CharT))
+ (replace(const_iterator, const_iterator, _InputIter, _InputIter))
+ (replace(const_iterator, const_iterator, initializer_list<_CharT>)):
+ Change const_iterator parameters to __const_iterator.
+ (insert(iterator, size_type, _CharT)): Add C++98 overload.
+ (insert(const_iterator, _InputIterator, _InputIterator)): Change
+ const_iterator parameter to __const_iterator.
+ [!_GLIBCXX_USE_CXX11_ABI]: Add workaround for incorrect return type
+ of base's member function.
+ (insert(const_iterator, size_type, _CharT)) [!_GLIBCXX_USE_CXX11_ABI]:
+ Likewise.
+ (insert(const_iterator, initializer_list<_CharT>))
+ [!_GLIBCXX_USE_CXX11_ABI]: Likewise.
+ * testsuite/21_strings/basic_string/init-list.cc: Remove effective
+ target directive.
+
* testsuite/20_util/reference_wrapper/lwg2993.cc: Fix C++11 test to
not use C++14 feature.
* testsuite/23_containers/list/68222_neg.cc: Likewise.
template<typename _ItT, typename _SeqT, typename _CatT>
friend class ::__gnu_debug::_Safe_iterator;
+ // type used for positions in insert, erase etc.
+ typedef __gnu_debug::_Safe_iterator<
+ typename _Base::__const_iterator, basic_string> __const_iterator;
+
public:
// types:
typedef _Traits traits_type;
}
iterator
- insert(const_iterator __p, _CharT __c)
+ insert(__const_iterator __p, _CharT __c)
{
__glibcxx_check_insert(__p);
typename _Base::iterator __res = _Base::insert(__p.base(), __c);
return iterator(__res, this);
}
+#if __cplusplus >= 201103L
iterator
insert(const_iterator __p, size_type __n, _CharT __c)
{
__glibcxx_check_insert(__p);
+#if _GLIBCXX_USE_CXX11_ABI
typename _Base::iterator __res = _Base::insert(__p.base(), __n, __c);
+#else
+ const size_type __offset = __p.base() - _Base::cbegin();
+ _Base::insert(_Base::begin() + __offset, __n, __c);
+ typename _Base::iterator __res = _Base::begin() + __offset;
+#endif
this->_M_invalidate_all();
return iterator(__res, this);
}
+#else
+ void
+ insert(iterator __p, size_type __n, _CharT __c)
+ {
+ __glibcxx_check_insert(__p);
+ _Base::insert(__p.base(), __n, __c);
+ this->_M_invalidate_all();
+ }
+#endif
template<typename _InputIterator>
iterator
- insert(const_iterator __p,
+ insert(__const_iterator __p,
_InputIterator __first, _InputIterator __last)
{
typename __gnu_debug::_Distance_traits<_InputIterator>::__type __dist;
__glibcxx_check_insert_range(__p, __first, __last, __dist);
typename _Base::iterator __res;
+#if _GLIBCXX_USE_CXX11_ABI
if (__dist.second >= __dp_sign)
__res = _Base::insert(__p.base(), __gnu_debug::__unsafe(__first),
__gnu_debug::__unsafe(__last));
else
__res = _Base::insert(__p.base(), __first, __last);
+#else
+ const size_type __offset = __p.base() - _Base::cbegin();
+ _Base::insert(__p.base(), __first, __last);
+ __res = _Base::begin() + __offset;
+#endif
this->_M_invalidate_all();
return iterator(__res, this);
}
insert(const_iterator __p, std::initializer_list<_CharT> __l)
{
__glibcxx_check_insert(__p);
+#if _GLIBCXX_USE_CXX11_ABI
const auto __res = _Base::insert(__p.base(), __l);
+#else
+ const size_type __offset = __p.base() - _Base::cbegin();
+ _Base::insert(_Base::begin() + __offset, __l);
+ auto __res = _Base::begin() + __offset;
+#endif
this->_M_invalidate_all();
return iterator(__res, this);
}
}
basic_string&
- replace(iterator __i1, iterator __i2, const basic_string& __str)
+ replace(__const_iterator __i1, __const_iterator __i2,
+ const basic_string& __str)
{
__glibcxx_check_erase_range(__i1, __i2);
_Base::replace(__i1.base(), __i2.base(), __str);
}
basic_string&
- replace(iterator __i1, iterator __i2, const _CharT* __s, size_type __n)
+ replace(__const_iterator __i1, __const_iterator __i2,
+ const _CharT* __s, size_type __n)
{
__glibcxx_check_erase_range(__i1, __i2);
__glibcxx_check_string_len(__s, __n);
}
basic_string&
- replace(iterator __i1, iterator __i2, const _CharT* __s)
+ replace(__const_iterator __i1, __const_iterator __i2,
+ const _CharT* __s)
{
__glibcxx_check_erase_range(__i1, __i2);
__glibcxx_check_string(__s);
}
basic_string&
- replace(iterator __i1, iterator __i2, size_type __n, _CharT __c)
+ replace(__const_iterator __i1, __const_iterator __i2,
+ size_type __n, _CharT __c)
{
__glibcxx_check_erase_range(__i1, __i2);
_Base::replace(__i1.base(), __i2.base(), __n, __c);
template<typename _InputIterator>
basic_string&
- replace(iterator __i1, iterator __i2,
+ replace(__const_iterator __i1, __const_iterator __i2,
_InputIterator __j1, _InputIterator __j2)
{
__glibcxx_check_erase_range(__i1, __i2);
}
#if __cplusplus >= 201103L
- basic_string& replace(iterator __i1, iterator __i2,
- std::initializer_list<_CharT> __l)
+ basic_string&
+ replace(__const_iterator __i1, __const_iterator __i2,
+ std::initializer_list<_CharT> __l)
{
__glibcxx_check_erase_range(__i1, __i2);
_Base::replace(__i1.base(), __i2.base(), __l);