From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20210 invoked by alias); 16 Apr 2002 00:50:55 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 20154 invoked from network); 16 Apr 2002 00:50:50 -0000 Received: from unknown (HELO ariane.ens-cachan.fr) (138.231.176.4) by sources.redhat.com with SMTP; 16 Apr 2002 00:50:50 -0000 Received: from mayo.cmla.ens-cachan.fr (mayo.cmla.ens-cachan.fr [138.231.64.2]) by ariane.ens-cachan.fr (8.12.2/jtpda-5.3.3) with ESMTP id g3G0okRp003587 ; Tue, 16 Apr 2002 02:50:46 +0200 Received: from jambon.cmla.ens-cachan.fr (jambon.cmla.ens-cachan.fr [138.231.64.60]) by mayo.cmla.ens-cachan.fr (8.9.1a/jtpda-5.3.2) with ESMTP id CAA00128 ; Tue, 16 Apr 2002 02:50:44 +0200 (MET DST) Received: from (dosreis@localhost) by jambon.cmla.ens-cachan.fr (8.9.3/jtpda-5.3.1/CL) id CAA24737 ; Tue, 16 Apr 2002 02:50:44 +0200 (MET DST) To: Mark Mitchell Cc: Joe Buck , Phil Edwards , gcc@gcc.gnu.org, bkoz@redhat.com, libstdc++@gcc.gnu.org Subject: Re: GCC 3.1 Release References: <550276201.1018457525@VAIO> From: Gabriel Dos Reis In-Reply-To: Mark Mitchell's message of "Wed, 10 Apr 2002 16:52:05 -0000" Organization: CodeSourcery, LLC Mime-Version: 1.0 (generated by tm-edit 7.106) Content-Type: text/plain; charset=US-ASCII Date: Mon, 15 Apr 2002 17:51:00 -0000 Message-ID: X-SW-Source: 2002-04/txt/msg00659.txt.bz2 Mark Mitchell writes: [...] | I think your patch makes sense. Benjamin what do you think? | | Gaby, if we can do something like this, it will definitely make things | easier for users. The standard specifies that std::rel_ops exists, and | it also specifies that iterators have an operator==, and it certainly | makes sense to make those two things work together if at all possible. Mark, Here is a patch to move the __normal_iterator<> bits into __gnu_cxx:: along with the patch suggested by Joe. It also incorporates Paolo's test. Bootstrapped and tested on i686-pc-linux-gnu (3.1 branch). I'll apply the same thing to mainline. Branch requires your approval if I understand correctly. -- Gaby Index: ChangeLog =================================================================== RCS file: /cvs/gcc/gcc/libstdc++-v3/ChangeLog,v retrieving revision 1.1057.2.73 diff -p -r1.1057.2.73 ChangeLog *** ChangeLog 15 Apr 2002 20:35:46 -0000 1.1057.2.73 --- ChangeLog 16 Apr 2002 00:42:15 -0000 *************** *** 1,3 **** --- 1,19 ---- + 2002-04-16 Paolo Carlini + * testsuite/24_iterators/rel_ops.cc: New test. + + 2002-04-16 Gabriel Dos Reis + + * include/bits/type_traits.h (__normal_iterator): Declare in + __gnu_cxx. Adjust use at global namespace. + * include/bits/stl_iterator.h (__normal_iterator): Move definition + into __gnu_cxx::. Add more operator overloads. Tidy existing ones. + * include/bits/basic_string.h (basic_string): Adjust use of + __normal_iterator. + * include/bits/stl_vector.h (_Alloc>): Likewise. + * src/concept-inst.cc (__gnu_cxx): __normal_iterator<> is now here. + * src/locale-inst.cc (__gnu_cxx): Likewise. + * src/string-inst.cc (operator==): Instantiate in __gnu_cxx. + 2002-04-15 Steve Ellcey * gcc/libstdc++-v3/config/os/hpux/bits/os_defines.h Index: include/bits/basic_string.h =================================================================== RCS file: /cvs/gcc/gcc/libstdc++-v3/include/bits/basic_string.h,v retrieving revision 1.19.2.2 diff -p -r1.19.2.2 basic_string.h *** include/bits/basic_string.h 1 Apr 2002 18:56:28 -0000 1.19.2.2 --- include/bits/basic_string.h 16 Apr 2002 00:42:16 -0000 *************** namespace std *** 99,106 **** typedef typename _Alloc::const_reference const_reference; typedef typename _Alloc::pointer pointer; typedef typename _Alloc::const_pointer const_pointer; ! typedef __normal_iterator iterator; ! typedef __normal_iterator const_iterator; typedef reverse_iterator const_reverse_iterator; typedef reverse_iterator reverse_iterator; --- 99,107 ---- typedef typename _Alloc::const_reference const_reference; typedef typename _Alloc::pointer pointer; typedef typename _Alloc::const_pointer const_pointer; ! typedef __gnu_cxx::__normal_iterator iterator; ! typedef __gnu_cxx::__normal_iterator ! const_iterator; typedef reverse_iterator const_reverse_iterator; typedef reverse_iterator reverse_iterator; Index: include/bits/stl_iterator.h =================================================================== RCS file: /cvs/gcc/gcc/libstdc++-v3/include/bits/stl_iterator.h,v retrieving revision 1.19 diff -p -r1.19 stl_iterator.h *** include/bits/stl_iterator.h 8 Feb 2002 07:34:54 -0000 1.19 --- include/bits/stl_iterator.h 16 Apr 2002 00:42:16 -0000 *************** namespace std *** 548,554 **** return insert_iterator<_Container>(__x, typename _Container::iterator(__i)); } ! // This iterator adapter is 'normal' in the sense that it does not // change the semantics of any of the operators of its iterator // parameter. Its primary purpose is to convert an iterator that is --- 548,557 ---- return insert_iterator<_Container>(__x, typename _Container::iterator(__i)); } ! } // namespace std ! ! namespace __gnu_cxx ! { // This iterator adapter is 'normal' in the sense that it does not // change the semantics of any of the operators of its iterator // parameter. Its primary purpose is to convert an iterator that is *************** namespace std *** 556,561 **** --- 559,566 ---- // The _Container parameter exists solely so that different containers // using this template can instantiate different types, even if the // _Iterator parameter is the same. + using std::iterator_traits; + using std::iterator; template class __normal_iterator : public iterator::iterator_category, *************** namespace std *** 632,637 **** --- 637,650 ---- base() const { return _M_current; } }; + // Note: In what follows, the left- and right-hand-side iterators are + // allowed to vary in types (conceptually in cv-qualification) so that + // comparaison between cv-qualified and non-cv-qualified iterators be + // valid. However, the greedy and unfriendly operators in std::rel_ops + // will make overload resolution ambiguous (when in scope) if we don't + // provide overloads whose operands are of the same type. Can someone + // remind me what generic programming is about? -- Gaby + // Forward iterator requirements template inline bool *************** namespace std *** 639,649 **** const __normal_iterator<_IteratorR, _Container>& __rhs) { return __lhs.base() == __rhs.base(); } template inline bool operator!=(const __normal_iterator<_IteratorL, _Container>& __lhs, const __normal_iterator<_IteratorR, _Container>& __rhs) ! { return !(__lhs == __rhs); } // Random access iterator requirements template --- 652,674 ---- const __normal_iterator<_IteratorR, _Container>& __rhs) { return __lhs.base() == __rhs.base(); } + template + inline bool + operator==(const __normal_iterator<_Iterator, _Container>& __lhs, + const __normal_iterator<_Iterator, _Container>& __rhs) + { return __lhs.base() == __rhs.base(); } + template inline bool operator!=(const __normal_iterator<_IteratorL, _Container>& __lhs, const __normal_iterator<_IteratorR, _Container>& __rhs) ! { return __lhs.base() != __rhs.base(); } ! ! template ! inline bool ! operator!=(const __normal_iterator<_Iterator, _Container>& __lhs, ! const __normal_iterator<_Iterator, _Container>& __rhs) ! { return __lhs.base() != __rhs.base(); } // Random access iterator requirements template *************** namespace std *** 652,681 **** const __normal_iterator<_IteratorR, _Container>& __rhs) { return __lhs.base() < __rhs.base(); } template inline bool operator>(const __normal_iterator<_IteratorL, _Container>& __lhs, const __normal_iterator<_IteratorR, _Container>& __rhs) ! { return __rhs < __lhs; } template inline bool operator<=(const __normal_iterator<_IteratorL, _Container>& __lhs, const __normal_iterator<_IteratorR, _Container>& __rhs) ! { return !(__rhs < __lhs); } template inline bool operator>=(const __normal_iterator<_IteratorL, _Container>& __lhs, const __normal_iterator<_IteratorR, _Container>& __rhs) ! { return !(__lhs < __rhs); } template inline __normal_iterator<_Iterator, _Container> operator+(typename __normal_iterator<_Iterator, _Container>::difference_type __n, const __normal_iterator<_Iterator, _Container>& __i) { return __normal_iterator<_Iterator, _Container>(__i.base() + __n); } ! } // namespace std #endif --- 677,730 ---- const __normal_iterator<_IteratorR, _Container>& __rhs) { return __lhs.base() < __rhs.base(); } + template + inline bool + operator<(const __normal_iterator<_Iterator, _Container>& __lhs, + const __normal_iterator<_Iterator, _Container>& __rhs) + { return __lhs.base() < __rhs.base(); } + template inline bool operator>(const __normal_iterator<_IteratorL, _Container>& __lhs, const __normal_iterator<_IteratorR, _Container>& __rhs) ! { return __lhs.base() > __rhs.base(); } ! ! template ! inline bool ! operator>(const __normal_iterator<_Iterator, _Container>& __lhs, ! const __normal_iterator<_Iterator, _Container>& __rhs) ! { return __lhs.base() > __rhs.base(); } template inline bool operator<=(const __normal_iterator<_IteratorL, _Container>& __lhs, const __normal_iterator<_IteratorR, _Container>& __rhs) ! { return __lhs.base() <= __rhs.base(); } ! ! template ! inline bool ! operator<=(const __normal_iterator<_Iterator, _Container>& __lhs, ! const __normal_iterator<_Iterator, _Container>& __rhs) ! { return __lhs.base() <= __rhs.base(); } template inline bool operator>=(const __normal_iterator<_IteratorL, _Container>& __lhs, const __normal_iterator<_IteratorR, _Container>& __rhs) ! { return __lhs.base() >= __rhs.base(); } ! ! template ! inline bool ! operator>=(const __normal_iterator<_Iterator, _Container>& __lhs, ! const __normal_iterator<_Iterator, _Container>& __rhs) ! { return __lhs.base() >= __rhs.base(); } template inline __normal_iterator<_Iterator, _Container> operator+(typename __normal_iterator<_Iterator, _Container>::difference_type __n, const __normal_iterator<_Iterator, _Container>& __i) { return __normal_iterator<_Iterator, _Container>(__i.base() + __n); } ! } // namespace __gnu_cxx #endif Index: include/bits/stl_vector.h =================================================================== RCS file: /cvs/gcc/gcc/libstdc++-v3/include/bits/stl_vector.h,v retrieving revision 1.17.2.2 diff -p -r1.17.2.2 stl_vector.h *** include/bits/stl_vector.h 27 Mar 2002 21:54:38 -0000 1.17.2.2 --- include/bits/stl_vector.h 16 Apr 2002 00:42:17 -0000 *************** public: *** 175,182 **** typedef _Tp value_type; typedef value_type* pointer; typedef const value_type* const_pointer; ! typedef __normal_iterator iterator; ! typedef __normal_iterator const_iterator; typedef value_type& reference; typedef const value_type& const_reference; typedef size_t size_type; --- 175,183 ---- typedef _Tp value_type; typedef value_type* pointer; typedef const value_type* const_pointer; ! typedef __gnu_cxx::__normal_iterator iterator; ! typedef __gnu_cxx::__normal_iterator ! const_iterator; typedef value_type& reference; typedef const value_type& const_reference; typedef size_t size_type; Index: include/bits/type_traits.h =================================================================== RCS file: /cvs/gcc/gcc/libstdc++-v3/include/bits/type_traits.h,v retrieving revision 1.11 diff -p -r1.11 type_traits.h *** include/bits/type_traits.h 2 Nov 2001 22:31:02 -0000 1.11 --- include/bits/type_traits.h 16 Apr 2002 00:42:17 -0000 *************** template struct _Is_normal *** 322,334 **** }; // Forward declaration hack, should really include this from somewhere. ! namespace std { template class __normal_iterator; } template ! struct _Is_normal_iterator< std::__normal_iterator<_Iterator, _Container> > { typedef __true_type _Normal; }; --- 322,334 ---- }; // Forward declaration hack, should really include this from somewhere. ! namespace __gnu_cxx { template class __normal_iterator; } template ! struct _Is_normal_iterator< __gnu_cxx::__normal_iterator<_Iterator, _Container> > { typedef __true_type _Normal; }; Index: src/concept-inst.cc =================================================================== RCS file: /cvs/gcc/gcc/libstdc++-v3/src/concept-inst.cc,v retrieving revision 1.3 diff -p -r1.3 concept-inst.cc *** src/concept-inst.cc 4 Jan 2002 21:27:35 -0000 1.3 --- src/concept-inst.cc 16 Apr 2002 00:42:17 -0000 *************** namespace __gnu_cxx *** 50,60 **** template void __aux_require_boolean_expr(bool const&); _Instantiate(_BidirectionalIteratorConcept< ! std::__normal_iterator< std::locale::facet**, std::vector > > > ); _Instantiate(_BidirectionalIteratorConcept< ! std::__normal_iterator< unsigned*, std::vector > > > ); _Instantiate(_ConvertibleConcept ); --- 50,60 ---- template void __aux_require_boolean_expr(bool const&); _Instantiate(_BidirectionalIteratorConcept< ! __normal_iterator< std::locale::facet**, std::vector > > > ); _Instantiate(_BidirectionalIteratorConcept< ! __normal_iterator< unsigned*, std::vector > > > ); _Instantiate(_ConvertibleConcept ); *************** namespace __gnu_cxx *** 68,82 **** _Instantiate(_InputIteratorConcept ); _Instantiate(_InputIteratorConcept< ! std::__normal_iterator< std::locale::facet* const*, std::vector > > > ); _Instantiate(_InputIteratorConcept< ! std::__normal_iterator< std::locale::facet**, std::vector > > > ); _Instantiate(_InputIteratorConcept< ! std::__normal_iterator< unsigned*, std::vector > > > ); #ifdef _GLIBCPP_USE_WCHAR_T --- 68,82 ---- _Instantiate(_InputIteratorConcept ); _Instantiate(_InputIteratorConcept< ! __normal_iterator< std::locale::facet* const*, std::vector > > > ); _Instantiate(_InputIteratorConcept< ! __normal_iterator< std::locale::facet**, std::vector > > > ); _Instantiate(_InputIteratorConcept< ! __normal_iterator< unsigned*, std::vector > > > ); #ifdef _GLIBCPP_USE_WCHAR_T *************** namespace __gnu_cxx *** 98,123 **** _Instantiate(_LessThanComparableConcept ); _Instantiate(_Mutable_BidirectionalIteratorConcept< ! std::__normal_iterator< std::locale::facet**, std::vector > > > ); _Instantiate(_Mutable_BidirectionalIteratorConcept< ! std::__normal_iterator< unsigned*, std::vector > > > ); _Instantiate(_Mutable_ForwardIteratorConcept< ! std::__normal_iterator< std::locale::facet**, std::vector > > > ); _Instantiate(_OutputIteratorConcept< std::locale::facet**, std::locale::facet*> ); _Instantiate(_OutputIteratorConcept< ! std::__normal_iterator< std::locale::facet**, std::vector > >, std::locale::facet* > ); ! _Instantiate(_OutputIteratorConcept > >, unsigned> ); _Instantiate(_OutputIteratorConcept ); _Instantiate(_Mutable_BidirectionalIteratorConcept< ! __normal_iterator< std::locale::facet**, std::vector > > > ); _Instantiate(_Mutable_BidirectionalIteratorConcept< ! __normal_iterator< unsigned*, std::vector > > > ); _Instantiate(_Mutable_ForwardIteratorConcept< ! __normal_iterator< std::locale::facet**, std::vector > > > ); _Instantiate(_OutputIteratorConcept< std::locale::facet**, std::locale::facet*> ); _Instantiate(_OutputIteratorConcept< ! __normal_iterator< std::locale::facet**, std::vector > >, std::locale::facet* > ); ! _Instantiate(_OutputIteratorConcept<__normal_iterator< unsigned*, std::vector > >, unsigned> ); _Instantiate(_OutputIteratorConcept ); _Instantiate(_RandomAccessIteratorConcept< ! std::__normal_iterator > ); _Instantiate(_RandomAccessIteratorConcept< ! std::__normal_iterator > ); #ifdef _GLIBCPP_USE_WCHAR_T _Instantiate(_RandomAccessIteratorConcept< ! std::__normal_iterator, std::allocator > > > ); _Instantiate(_RandomAccessIteratorConcept< ! std::__normal_iterator, std::allocator > > > ); --- 133,151 ---- _Instantiate(_RandomAccessIteratorConcept ); _Instantiate(_RandomAccessIteratorConcept< ! __normal_iterator > ); _Instantiate(_RandomAccessIteratorConcept< ! __normal_iterator > ); #ifdef _GLIBCPP_USE_WCHAR_T _Instantiate(_RandomAccessIteratorConcept< ! __normal_iterator, std::allocator > > > ); _Instantiate(_RandomAccessIteratorConcept< ! __normal_iterator, std::allocator > > > ); Index: src/locale-inst.cc =================================================================== RCS file: /cvs/gcc/gcc/libstdc++-v3/src/locale-inst.cc,v retrieving revision 1.29.2.2 diff -p -r1.29.2.2 locale-inst.cc *** src/locale-inst.cc 25 Mar 2002 21:49:09 -0000 1.29.2.2 --- src/locale-inst.cc 16 Apr 2002 00:42:17 -0000 *************** namespace std *** 410,422 **** has_facet >(const locale&); #endif - // iterator - typedef vector vec_pfacet; template class vector; ! template class __normal_iterator >; ! template class __normal_iterator >; // locale template char* --- 410,428 ---- has_facet >(const locale&); #endif template class vector; ! } // namespace std ! ! namespace __gnu_cxx ! { ! // iterator ! typedef std::vector vec_pfacet; ! template class __normal_iterator; ! template class __normal_iterator; ! } // namespace __gnu_cxx + namespace std + { // locale template char* *************** namespace std *** 490,495 **** --- 496,502 ---- fill_n (locale::facet**, size_t, locale::facet* const&); + using __gnu_cxx::__normal_iterator; template __normal_iterator > fill_n(__normal_iterator >, Index: src/string-inst.cc =================================================================== RCS file: /cvs/gcc/gcc/libstdc++-v3/src/string-inst.cc,v retrieving revision 1.24 diff -p -r1.24 string-inst.cc *** src/string-inst.cc 16 Feb 2002 00:19:13 -0000 1.24 --- src/string-inst.cc 16 Apr 2002 00:42:17 -0000 *************** namespace std *** 48,56 **** --- 48,64 ---- template class basic_string; template S operator+(const C*, const S&); template S operator+(C, const S&); + } // namespace std + + namespace __gnu_cxx + { + using std::S; template bool operator==(const S::iterator&, const S::iterator&); template bool operator==(const S::const_iterator&, const S::const_iterator&); + } + namespace std + { // Only one template keyword allowed here. // See core issue #46 (NAD) // http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/cwg_closed.html#46 Index: testsuite/24_iterators/rel_ops.cc =================================================================== RCS file: testsuite/24_iterators/rel_ops.cc diff -N testsuite/24_iterators/rel_ops.cc *** /dev/null 1 Jan 1970 00:00:00 -0000 --- testsuite/24_iterators/rel_ops.cc 16 Apr 2002 00:42:17 -0000 *************** *** 0 **** --- 1,45 ---- + // 2002-04-13 Paolo Carlini + + // Copyright (C) 2002 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, + // USA. + + // 20.2.1 Operators + + #include + #include + + using namespace std::rel_ops; + + // libstdc++/3628 + void test01() + { + std::vector v; + std::vector::iterator vi; + + vi != v.begin(); + vi > v.begin(); + vi <= v.begin(); + vi >= v.begin(); + } + + int main() + { + test01(); + return 0; + } +