diff options
author | paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-10-05 15:49:39 +0000 |
---|---|---|
committer | paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-10-05 15:49:39 +0000 |
commit | 2a2f3111f782428b71f15bc1093ee576779f83d1 (patch) | |
tree | cdc0710f99223246209e7540adfe9c8d9412d219 /libstdc++-v3 | |
parent | c5b3a71bb105292f55f535bd5d5e0bb048c8deef (diff) | |
download | gcc-2a2f3111f782428b71f15bc1093ee576779f83d1.tar.gz |
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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@105000 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3')
-rw-r--r-- | libstdc++-v3/ChangeLog | 9 | ||||
-rw-r--r-- | libstdc++-v3/docs/html/ext/howto.html | 7 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/stl_iterator.h | 49 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/24_iterators/reverse_iterator/11729.cc | 73 |
4 files changed, 136 insertions, 2 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 1d0fc12d4b4..940f6ab45dc 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -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 diff --git a/libstdc++-v3/docs/html/ext/howto.html b/libstdc++-v3/docs/html/ext/howto.html index 85161964e5f..b22b56e0622 100644 --- a/libstdc++-v3/docs/html/ext/howto.html +++ b/libstdc++-v3/docs/html/ext/howto.html @@ -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> diff --git a/libstdc++-v3/include/bits/stl_iterator.h b/libstdc++-v3/include/bits/stl_iterator.h index 5b8cf65e6d8..4c4630a0689 100644 --- a/libstdc++-v3/include/bits/stl_iterator.h +++ b/libstdc++-v3/include/bits/stl_iterator.h @@ -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 diff --git a/libstdc++-v3/testsuite/24_iterators/reverse_iterator/11729.cc b/libstdc++-v3/testsuite/24_iterators/reverse_iterator/11729.cc new file mode 100644 index 00000000000..f79be3ebb4c --- /dev/null +++ b/libstdc++-v3/testsuite/24_iterators/reverse_iterator/11729.cc @@ -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; +} |