[multiple changes]

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/locale-inst.cc (__gnu_cxx): Likewise.
    * src/string-inst.cc (operator==): Instantiate in  __gnu_cxx.

From-SVN: r52351
This commit is contained in:
Gabriel Dos Reis 2002-04-16 02:53:23 +00:00
parent 8017720c01
commit 5b25ca6833
8 changed files with 113 additions and 31 deletions

View File

@ -1,3 +1,19 @@
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/locale-inst.cc (__gnu_cxx): Likewise.
* src/string-inst.cc (operator==): Instantiate in __gnu_cxx.
2002-04-15 Steve Ellcey <sje@cup.hp.com>
* gcc/libstdc++-v3/config/os/hpux/bits/os_defines.h

View File

@ -99,8 +99,9 @@ namespace std
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;

View File

@ -548,7 +548,10 @@ namespace std
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
@ -556,6 +559,8 @@ namespace std
// 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,
@ -632,6 +637,14 @@ namespace std
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
@ -639,11 +652,23 @@ namespace std
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>
@ -652,30 +677,54 @@ namespace std
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

View File

@ -175,8 +175,9 @@ public:
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;

View File

@ -322,13 +322,13 @@ template<typename _Tp> struct _Is_normal_iterator {
};
// 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;
};

View File

@ -50,11 +50,11 @@ namespace __gnu_cxx
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*> );
@ -68,15 +68,15 @@ namespace __gnu_cxx
_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
@ -98,26 +98,26 @@ namespace __gnu_cxx
_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<
@ -133,19 +133,19 @@ namespace __gnu_cxx
_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> > > > );

View File

@ -410,13 +410,19 @@ namespace std
has_facet<messages<wchar_t> >(const locale&);
#endif
// iterator
typedef vector<locale::facet*> vec_pfacet;
template class vector<locale::facet*>;
template class __normal_iterator<locale::facet**, vector<locale::facet*> >;
template class __normal_iterator<locale::facet* const*,
vector<locale::facet*> >;
} // namespace std
namespace __gnu_cxx
{
// iterator
typedef std::vector<std::locale::facet*> vec_pfacet;
template class __normal_iterator<std::locale::facet**, vec_pfacet >;
template class __normal_iterator<std::locale::facet* const*, vec_pfacet>;
} // namespace __gnu_cxx
namespace std
{
// locale
template
char*
@ -490,6 +496,7 @@ namespace std
fill_n<locale::facet**, size_t, locale::facet*>
(locale::facet**, size_t, locale::facet* const&);
using __gnu_cxx::__normal_iterator;
template
__normal_iterator<locale::facet**, vector<locale::facet*> >
fill_n(__normal_iterator<locale::facet**, vector<locale::facet*> >,

View File

@ -48,9 +48,17 @@ namespace std
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