summaryrefslogtreecommitdiff
path: root/libstdc++-v3/include
diff options
context:
space:
mode:
authorpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>2005-12-06 17:19:30 +0000
committerpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>2005-12-06 17:19:30 +0000
commite121346565f78f1a88859d7096f0e7f8049e7721 (patch)
tree910230266a33d36f91eb5e255199e42cb826cade /libstdc++-v3/include
parentb463ae9b5c8f1e571692ffbfd8c5e2181076df2a (diff)
downloadgcc-e121346565f78f1a88859d7096f0e7f8049e7721.tar.gz
2005-12-06 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.h (insert(iterator, _CharT), erase(iterator), erase(iterator, iterator)): Avoid troubles with ADL, user defined operators and __normal_iterator. * include/bits/stl_iterator.h (operator-(const __normal_iterator <_Iterator, _Container>&, const __normal_iterator<_Iterator, _Container>&)): Add overload for left and right iterators of the same type. * include/debug/safe_iterator.h (operator-(const _Safe_iterator <_Iterator, _Sequence>&, const _Safe_iterator<_Iterator, _Sequence>&)): Likewise. * testsuite/21_strings/basic_string/types/1.cc: New. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@108123 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/include')
-rw-r--r--libstdc++-v3/include/bits/basic_string.h6
-rw-r--r--libstdc++-v3/include/bits/stl_iterator.h6
-rw-r--r--libstdc++-v3/include/debug/safe_iterator.h16
3 files changed, 25 insertions, 3 deletions
diff --git a/libstdc++-v3/include/bits/basic_string.h b/libstdc++-v3/include/bits/basic_string.h
index 8623c8db7fe..0ff2e54e8d3 100644
--- a/libstdc++-v3/include/bits/basic_string.h
+++ b/libstdc++-v3/include/bits/basic_string.h
@@ -1097,7 +1097,7 @@ namespace std
const size_type __pos = __p - _M_ibegin();
_M_replace_aux(__pos, size_type(0), size_type(1), __c);
_M_rep()->_M_set_leaked();
- return this->_M_ibegin() + __pos;
+ return iterator(_M_data() + __pos);
}
/**
@@ -1138,7 +1138,7 @@ namespace std
const size_type __pos = __position - _M_ibegin();
_M_mutate(__pos, size_type(1), size_type(0));
_M_rep()->_M_set_leaked();
- return _M_ibegin() + __pos;
+ return iterator(_M_data() + __pos);
}
/**
@@ -1158,7 +1158,7 @@ namespace std
const size_type __pos = __first - _M_ibegin();
_M_mutate(__pos, __last - __first, size_type(0));
_M_rep()->_M_set_leaked();
- return _M_ibegin() + __pos;
+ return iterator(_M_data() + __pos);
}
/**
diff --git a/libstdc++-v3/include/bits/stl_iterator.h b/libstdc++-v3/include/bits/stl_iterator.h
index 4c4630a0689..12b2e9c6f9a 100644
--- a/libstdc++-v3/include/bits/stl_iterator.h
+++ b/libstdc++-v3/include/bits/stl_iterator.h
@@ -809,6 +809,12 @@ namespace __gnu_cxx
{ return __lhs.base() - __rhs.base(); }
template<typename _Iterator, typename _Container>
+ inline typename __normal_iterator<_Iterator, _Container>::difference_type
+ operator-(const __normal_iterator<_Iterator, _Container>& __lhs,
+ const __normal_iterator<_Iterator, _Container>& __rhs)
+ { return __lhs.base() - __rhs.base(); }
+
+ template<typename _Iterator, typename _Container>
inline __normal_iterator<_Iterator, _Container>
operator+(typename __normal_iterator<_Iterator, _Container>::difference_type
__n, const __normal_iterator<_Iterator, _Container>& __i)
diff --git a/libstdc++-v3/include/debug/safe_iterator.h b/libstdc++-v3/include/debug/safe_iterator.h
index 0ff967eea54..c497c113c88 100644
--- a/libstdc++-v3/include/debug/safe_iterator.h
+++ b/libstdc++-v3/include/debug/safe_iterator.h
@@ -607,6 +607,22 @@ namespace __gnu_debug
return __lhs.base() - __rhs.base();
}
+ template<typename _Iterator, typename _Sequence>
+ inline typename _Safe_iterator<_Iterator, _Sequence>::difference_type
+ operator-(const _Safe_iterator<_Iterator, _Sequence>& __lhs,
+ const _Safe_iterator<_Iterator, _Sequence>& __rhs)
+ {
+ _GLIBCXX_DEBUG_VERIFY(! __lhs._M_singular() && ! __rhs._M_singular(),
+ _M_message(__msg_distance_bad)
+ ._M_iterator(__lhs, "lhs")
+ ._M_iterator(__rhs, "rhs"));
+ _GLIBCXX_DEBUG_VERIFY(__lhs._M_can_compare(__rhs),
+ _M_message(__msg_distance_different)
+ ._M_iterator(__lhs, "lhs")
+ ._M_iterator(__rhs, "rhs"));
+ return __lhs.base() - __rhs.base();
+ }
+
template<typename _Iterator, typename _Sequence>
inline _Safe_iterator<_Iterator, _Sequence>
operator+(typename _Safe_iterator<_Iterator,_Sequence>::difference_type __n,