re PR libstdc++/6642 (Constness prevents substraction of iterators)
2002-07-02 Paolo Carlini <pcarlini@unitus.it> PR libstdc++/6642 * include/bits/stl_iterator.h (__normal_iterator::operator-(const __normal_iterator&)): Make non-member, as already happens for the comparison operators in accord with DR179 (Ready). * testsuite/24_iterators/iterator.cc: Add test from the PR. From-SVN: r55188
This commit is contained in:
parent
981869348c
commit
d16ecaec1d
3 changed files with 32 additions and 4 deletions
|
@ -1,3 +1,12 @@
|
|||
2002-07-02 Paolo Carlini <pcarlini@unitus.it>
|
||||
|
||||
PR libstdc++/6642
|
||||
* include/bits/stl_iterator.h
|
||||
(__normal_iterator::operator-(const __normal_iterator&)):
|
||||
Make non-member, as already happens for the comparison
|
||||
operators in accord with DR179 (Ready).
|
||||
* testsuite/24_iterators/iterator.cc: Add test from the PR.
|
||||
|
||||
2002-07-02 Phil Edwards <pme@gcc.gnu.org>
|
||||
|
||||
PR libstdc++/7173
|
||||
|
|
|
@ -629,10 +629,6 @@ namespace __gnu_cxx
|
|||
operator-(const difference_type& __n) const
|
||||
{ return __normal_iterator(_M_current - __n); }
|
||||
|
||||
difference_type
|
||||
operator-(const __normal_iterator& __i) const
|
||||
{ return _M_current - __i._M_current; }
|
||||
|
||||
const _Iterator&
|
||||
base() const { return _M_current; }
|
||||
};
|
||||
|
@ -719,6 +715,16 @@ namespace __gnu_cxx
|
|||
const __normal_iterator<_Iterator, _Container>& __rhs)
|
||||
{ return __lhs.base() >= __rhs.base(); }
|
||||
|
||||
// _GLIBCPP_RESOLVE_LIB_DEFECTS
|
||||
// According to the resolution of DR179 not only the various comparison
|
||||
// operators but also operator- must accept mixed iterator/const_iterator
|
||||
// parameters.
|
||||
template<typename _IteratorL, typename _IteratorR, typename _Container>
|
||||
inline typename __normal_iterator<_IteratorL, _Container>::difference_type
|
||||
operator-(const __normal_iterator<_IteratorL, _Container>& __lhs,
|
||||
const __normal_iterator<_IteratorR, _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,
|
||||
|
|
|
@ -577,6 +577,17 @@ wrong_stuff()
|
|||
return failures;
|
||||
}
|
||||
|
||||
// libstdc++/6642
|
||||
int
|
||||
test6642()
|
||||
{
|
||||
std::string s;
|
||||
std::string::iterator it = s.begin();
|
||||
std::string::const_iterator cit = s.begin();
|
||||
|
||||
return it - cit;
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
|
@ -590,6 +601,8 @@ main(int argc, char **argv)
|
|||
|
||||
failures += wrong_stuff();
|
||||
|
||||
failures += test6642();
|
||||
|
||||
#ifdef DEBUG_ASSERT
|
||||
assert (failures == 0);
|
||||
#endif
|
||||
|
|
Loading…
Add table
Reference in a new issue