PR libstdc++/11729 (DR 280, [Ready])
2005-10-05 Paolo Carlini <pcarlini@suse.de> PR libstdc++/11729 (DR 280, [Ready]) * include/bits/stl_iterator.h: Add reverse_iterator global functions with two template parameters (operator==, !=, <, >, <=, >=, -). * testsuite/24_iterators/reverse_iterator/11729.cc: New. * docs/html/ext/howto.html: Add an entry for issue 280. From-SVN: r105000
This commit is contained in:
parent
c2540bbb46
commit
c6ff194494
@ -1,3 +1,12 @@
|
||||
2005-10-05 Paolo Carlini <pcarlini@suse.de>
|
||||
|
||||
PR libstdc++/11729 (DR 280, [Ready])
|
||||
* include/bits/stl_iterator.h: Add reverse_iterator global
|
||||
functions with two template parameters (operator==, !=, <,
|
||||
>, <=, >=, -).
|
||||
* testsuite/24_iterators/reverse_iterator/11729.cc: New.
|
||||
* docs/html/ext/howto.html: Add an entry for issue 280.
|
||||
|
||||
2005-10-03 Paolo Carlini <pcarlini@suse.de>
|
||||
|
||||
* include/tr1/hashtable
|
||||
|
@ -453,6 +453,13 @@
|
||||
<dd>Similar to 118.
|
||||
</dd>
|
||||
|
||||
<dt><a href="lwg-active.html#280">280</a>:
|
||||
<em>Comparison of reverse_iterator to const reverse_iterator</em>
|
||||
</dt>
|
||||
<dd>Add global functions with two template parameters.
|
||||
(NB: not added for now a templated assignment operator)
|
||||
</dd>
|
||||
|
||||
<dt><a href="lwg-defects.html#292">292</a>:
|
||||
<em>Effects of a.copyfmt (a)</em>
|
||||
</dt>
|
||||
|
@ -205,7 +205,8 @@ namespace std
|
||||
*
|
||||
* @doctodo
|
||||
*/
|
||||
reverse_iterator operator--(int)
|
||||
reverse_iterator
|
||||
operator--(int)
|
||||
{
|
||||
reverse_iterator __tmp = *this;
|
||||
++current;
|
||||
@ -301,7 +302,7 @@ namespace std
|
||||
template<typename _Iterator>
|
||||
inline bool
|
||||
operator<=(const reverse_iterator<_Iterator>& __x,
|
||||
const reverse_iterator<_Iterator>& __y)
|
||||
const reverse_iterator<_Iterator>& __y)
|
||||
{ return !(__y < __x); }
|
||||
|
||||
template<typename _Iterator>
|
||||
@ -321,6 +322,50 @@ namespace std
|
||||
operator+(typename reverse_iterator<_Iterator>::difference_type __n,
|
||||
const reverse_iterator<_Iterator>& __x)
|
||||
{ return reverse_iterator<_Iterator>(__x.base() - __n); }
|
||||
|
||||
// _GLIBCXX_RESOLVE_LIB_DEFECTS
|
||||
// DR 280. Comparison of reverse_iterator to const reverse_iterator.
|
||||
template<typename _IteratorL, typename _IteratorR>
|
||||
inline bool
|
||||
operator==(const reverse_iterator<_IteratorL>& __x,
|
||||
const reverse_iterator<_IteratorR>& __y)
|
||||
{ return __x.base() == __y.base(); }
|
||||
|
||||
template<typename _IteratorL, typename _IteratorR>
|
||||
inline bool
|
||||
operator<(const reverse_iterator<_IteratorL>& __x,
|
||||
const reverse_iterator<_IteratorR>& __y)
|
||||
{ return __y.base() < __x.base(); }
|
||||
|
||||
template<typename _IteratorL, typename _IteratorR>
|
||||
inline bool
|
||||
operator!=(const reverse_iterator<_IteratorL>& __x,
|
||||
const reverse_iterator<_IteratorR>& __y)
|
||||
{ return !(__x == __y); }
|
||||
|
||||
template<typename _IteratorL, typename _IteratorR>
|
||||
inline bool
|
||||
operator>(const reverse_iterator<_IteratorL>& __x,
|
||||
const reverse_iterator<_IteratorR>& __y)
|
||||
{ return __y < __x; }
|
||||
|
||||
template<typename _IteratorL, typename _IteratorR>
|
||||
inline bool
|
||||
operator<=(const reverse_iterator<_IteratorL>& __x,
|
||||
const reverse_iterator<_IteratorR>& __y)
|
||||
{ return !(__y < __x); }
|
||||
|
||||
template<typename _IteratorL, typename _IteratorR>
|
||||
inline bool
|
||||
operator>=(const reverse_iterator<_IteratorL>& __x,
|
||||
const reverse_iterator<_IteratorR>& __y)
|
||||
{ return !(__x < __y); }
|
||||
|
||||
template<typename _IteratorL, typename _IteratorR>
|
||||
inline typename reverse_iterator<_IteratorL>::difference_type
|
||||
operator-(const reverse_iterator<_IteratorL>& __x,
|
||||
const reverse_iterator<_IteratorR>& __y)
|
||||
{ return __y.base() - __x.base(); }
|
||||
//@}
|
||||
|
||||
// 24.4.2.2.1 back_insert_iterator
|
||||
|
@ -0,0 +1,73 @@
|
||||
// 2005-10-04 Paolo Carlini <pcarlini@suse.de>
|
||||
|
||||
// Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; you can redistribute it and/or modify it under the
|
||||
// terms of the GNU General Public License as published by the
|
||||
// Free Software Foundation; either version 2, or (at your option)
|
||||
// any later version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with this library; see the file COPYING. If not, write to the Free
|
||||
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
// USA.
|
||||
|
||||
// 24.4.1.2 Reverse iterators
|
||||
|
||||
#include <vector>
|
||||
#include <testsuite_hooks.h>
|
||||
|
||||
// libstdc++/11729
|
||||
void test01()
|
||||
{
|
||||
bool test __attribute__((unused)) = true;
|
||||
|
||||
typedef std::vector<int> Vec;
|
||||
typedef Vec::reverse_iterator reverse_iterator;
|
||||
typedef Vec::const_reverse_iterator const_reverse_iterator;
|
||||
|
||||
Vec v(2);
|
||||
|
||||
reverse_iterator rbeg = v.rbegin();
|
||||
reverse_iterator rend = v.rend();
|
||||
const_reverse_iterator constrbeg(rbeg);
|
||||
const_reverse_iterator constrend(rend);
|
||||
|
||||
VERIFY( rbeg == constrbeg );
|
||||
VERIFY( constrend == rend );
|
||||
|
||||
VERIFY( rbeg != constrend );
|
||||
VERIFY( constrbeg != rend );
|
||||
|
||||
VERIFY( rbeg < constrend );
|
||||
VERIFY( constrbeg < rend );
|
||||
|
||||
VERIFY( rend > constrbeg );
|
||||
VERIFY( constrend > rbeg );
|
||||
|
||||
VERIFY( rend >= constrend );
|
||||
VERIFY( constrbeg >= rbeg );
|
||||
|
||||
VERIFY( rbeg <= constrbeg );
|
||||
VERIFY( constrend <= rend );
|
||||
|
||||
VERIFY( rbeg - constrbeg == 0 );
|
||||
VERIFY( constrend - rend == 0 );
|
||||
|
||||
VERIFY( rend - constrbeg > 0 );
|
||||
VERIFY( constrend - rbeg > 0 );
|
||||
|
||||
VERIFY( (constrbeg = rend) == rend );
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test01();
|
||||
return 0;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user