+2002-04-16 Paolo Carlini <pcarlini@unitus.it>
+ * testsuite/24_iterators/rel_ops.cc: New test.
+
+2002-04-16 Gabriel Dos Reis <gdr@merlin.codesourcery.com>
+
+ * 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/string-inst.cc (operator==): Instantiate in __gnu_cxx.
+
2002-04-15 Benjamin Kosnik <bkoz@redhat.com>
PR libstdc++/4164
typedef typename _Alloc::const_reference const_reference;
typedef typename _Alloc::pointer pointer;
typedef typename _Alloc::const_pointer const_pointer;
- typedef __normal_iterator<pointer, basic_string> iterator;
- typedef __normal_iterator<const_pointer, basic_string> const_iterator;
+ typedef __gnu_cxx::__normal_iterator<pointer, basic_string> iterator;
+ typedef __gnu_cxx::__normal_iterator<const_pointer, basic_string>
+ const_iterator;
typedef reverse_iterator<const_iterator> const_reverse_iterator;
typedef reverse_iterator<iterator> reverse_iterator;
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
// 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<typename _Iterator, typename _Container>
class __normal_iterator
: public iterator<typename iterator_traits<_Iterator>::iterator_category,
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<typename _IteratorL, typename _IteratorR, typename _Container>
inline bool
const __normal_iterator<_IteratorR, _Container>& __rhs)
{ return __lhs.base() == __rhs.base(); }
+ template<typename _Iterator, typename _Container>
+ inline bool
+ operator==(const __normal_iterator<_Iterator, _Container>& __lhs,
+ const __normal_iterator<_Iterator, _Container>& __rhs)
+ { return __lhs.base() == __rhs.base(); }
+
template<typename _IteratorL, typename _IteratorR, typename _Container>
inline bool
operator!=(const __normal_iterator<_IteratorL, _Container>& __lhs,
const __normal_iterator<_IteratorR, _Container>& __rhs)
- { return !(__lhs == __rhs); }
+ { return __lhs.base() != __rhs.base(); }
+
+ template<typename _Iterator, typename _Container>
+ 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<typename _IteratorL, typename _IteratorR, typename _Container>
const __normal_iterator<_IteratorR, _Container>& __rhs)
{ return __lhs.base() < __rhs.base(); }
+ template<typename _Iterator, typename _Container>
+ inline bool
+ operator<(const __normal_iterator<_Iterator, _Container>& __lhs,
+ const __normal_iterator<_Iterator, _Container>& __rhs)
+ { return __lhs.base() < __rhs.base(); }
+
template<typename _IteratorL, typename _IteratorR, typename _Container>
inline bool
operator>(const __normal_iterator<_IteratorL, _Container>& __lhs,
const __normal_iterator<_IteratorR, _Container>& __rhs)
- { return __rhs < __lhs; }
+ { return __lhs.base() > __rhs.base(); }
+
+ template<typename _Iterator, typename _Container>
+ inline bool
+ operator>(const __normal_iterator<_Iterator, _Container>& __lhs,
+ const __normal_iterator<_Iterator, _Container>& __rhs)
+ { return __lhs.base() > __rhs.base(); }
template<typename _IteratorL, typename _IteratorR, typename _Container>
inline bool
operator<=(const __normal_iterator<_IteratorL, _Container>& __lhs,
const __normal_iterator<_IteratorR, _Container>& __rhs)
- { return !(__rhs < __lhs); }
+ { return __lhs.base() <= __rhs.base(); }
+
+ template<typename _Iterator, typename _Container>
+ inline bool
+ operator<=(const __normal_iterator<_Iterator, _Container>& __lhs,
+ const __normal_iterator<_Iterator, _Container>& __rhs)
+ { return __lhs.base() <= __rhs.base(); }
template<typename _IteratorL, typename _IteratorR, typename _Container>
inline bool
operator>=(const __normal_iterator<_IteratorL, _Container>& __lhs,
const __normal_iterator<_IteratorR, _Container>& __rhs)
- { return !(__lhs < __rhs); }
+ { return __lhs.base() >= __rhs.base(); }
+
+ template<typename _Iterator, typename _Container>
+ inline bool
+ 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)
{ return __normal_iterator<_Iterator, _Container>(__i.base() + __n); }
-} // namespace std
+} // namespace __gnu_cxx
#endif
typedef _Tp value_type;
typedef value_type* pointer;
typedef const value_type* const_pointer;
- typedef __normal_iterator<pointer, vector_type> iterator;
- typedef __normal_iterator<const_pointer, vector_type> const_iterator;
+ typedef __gnu_cxx::__normal_iterator<pointer, vector_type> iterator;
+ typedef __gnu_cxx::__normal_iterator<const_pointer, vector_type>
+ const_iterator;
typedef value_type& reference;
typedef const value_type& const_reference;
typedef size_t size_type;
};
// Forward declaration hack, should really include this from somewhere.
-namespace std
+namespace __gnu_cxx
{
template<typename _Iterator, typename _Container> class __normal_iterator;
}
template<typename _Iterator, typename _Container>
-struct _Is_normal_iterator< std::__normal_iterator<_Iterator, _Container> > {
+struct _Is_normal_iterator< __gnu_cxx::__normal_iterator<_Iterator, _Container> > {
typedef __true_type _Normal;
};
template void __aux_require_boolean_expr<bool>(bool const&);
_Instantiate(_BidirectionalIteratorConcept<
- std::__normal_iterator< std::locale::facet**,
+ __normal_iterator< std::locale::facet**,
std::vector<std::locale::facet*,std::allocator<std::locale::facet*> > > > );
_Instantiate(_BidirectionalIteratorConcept<
- std::__normal_iterator< unsigned*,
+ __normal_iterator< unsigned*,
std::vector<unsigned, std::allocator<unsigned> > > > );
_Instantiate(_ConvertibleConcept<std::locale::facet*, std::locale::facet*> );
_Instantiate(_InputIteratorConcept<std::locale::facet**> );
_Instantiate(_InputIteratorConcept<
- std::__normal_iterator< std::locale::facet* const*,
+ __normal_iterator< std::locale::facet* const*,
std::vector<std::locale::facet*,std::allocator<std::locale::facet*> > > > );
_Instantiate(_InputIteratorConcept<
- std::__normal_iterator< std::locale::facet**,
+ __normal_iterator< std::locale::facet**,
std::vector<std::locale::facet*,std::allocator<std::locale::facet*> > > > );
_Instantiate(_InputIteratorConcept<
- std::__normal_iterator< unsigned*,
+ __normal_iterator< unsigned*,
std::vector<unsigned, std::allocator<unsigned> > > > );
#ifdef _GLIBCPP_USE_WCHAR_T
_Instantiate(_LessThanComparableConcept<unsigned> );
_Instantiate(_Mutable_BidirectionalIteratorConcept<
- std::__normal_iterator< std::locale::facet**,
+ __normal_iterator< std::locale::facet**,
std::vector<std::locale::facet*,std::allocator<std::locale::facet*> > > > );
_Instantiate(_Mutable_BidirectionalIteratorConcept<
- std::__normal_iterator< unsigned*,
+ __normal_iterator< unsigned*,
std::vector<unsigned, std::allocator<unsigned> > > > );
_Instantiate(_Mutable_ForwardIteratorConcept<
- std::__normal_iterator< std::locale::facet**,
+ __normal_iterator< std::locale::facet**,
std::vector<std::locale::facet*,std::allocator<std::locale::facet*> > > > );
_Instantiate(_OutputIteratorConcept<
std::locale::facet**, std::locale::facet*> );
_Instantiate(_OutputIteratorConcept<
- std::__normal_iterator< std::locale::facet**,
+ __normal_iterator< std::locale::facet**,
std::vector<std::locale::facet*, std::allocator<std::locale::facet* > > >,
std::locale::facet* > );
- _Instantiate(_OutputIteratorConcept<std::__normal_iterator<
+ _Instantiate(_OutputIteratorConcept<__normal_iterator<
unsigned*, std::vector<unsigned, std::allocator<unsigned> > >, unsigned> );
_Instantiate(_OutputIteratorConcept<std::ostreambuf_iterator<
_Instantiate(_RandomAccessIteratorConcept<char const*> );
_Instantiate(_RandomAccessIteratorConcept<
- std::__normal_iterator<char const*, std::string> > );
+ __normal_iterator<char const*, std::string> > );
_Instantiate(_RandomAccessIteratorConcept<
- std::__normal_iterator<char*, std::string> > );
+ __normal_iterator<char*, std::string> > );
#ifdef _GLIBCPP_USE_WCHAR_T
_Instantiate(_RandomAccessIteratorConcept<
- std::__normal_iterator<wchar_t const*,
+ __normal_iterator<wchar_t const*,
std::basic_string<wchar_t, std::char_traits<wchar_t>,
std::allocator<wchar_t> > > > );
_Instantiate(_RandomAccessIteratorConcept<
- std::__normal_iterator<wchar_t*,
+ __normal_iterator<wchar_t*,
std::basic_string<wchar_t, std::char_traits<wchar_t>,
std::allocator<wchar_t> > > > );
template class basic_string<C>;
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
--- /dev/null
+// 2002-04-13 Paolo Carlini <pcarlini@unitus.it>
+
+// 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 <utility>
+#include <vector>
+
+using namespace std::rel_ops;
+
+// libstdc++/3628
+void test01()
+{
+ std::vector<int> v;
+ std::vector<int>::iterator vi;
+
+ vi != v.begin();
+ vi > v.begin();
+ vi <= v.begin();
+ vi >= v.begin();
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
+