From 3adc5bcd39e19aaf3e6728a8abf8efc75e07af52 Mon Sep 17 00:00:00 2001 From: Rene Brun <Rene.Brun@cern.ch> Date: Mon, 12 Jan 2004 14:27:52 +0000 Subject: [PATCH] Mods by Philippe to install the new version under VC++7 git-svn-id: http://root.cern.ch/svn/root/trunk@7886 27541ba8-7e3a-0410-8455-c3a389f83636 --- cint/lib/prec_stl/iterator | 1545 ++++++++++++++++++++++-------------- cint/lib/prec_stl/vector | 986 ++++++++++++----------- 2 files changed, 1483 insertions(+), 1048 deletions(-) diff --git a/cint/lib/prec_stl/iterator b/cint/lib/prec_stl/iterator index 4128c48d108..98a80e91eef 100644 --- a/cint/lib/prec_stl/iterator +++ b/cint/lib/prec_stl/iterator @@ -1,596 +1,949 @@ -// lib/prec_stl/iterator - -#pragma ifndef PREC_STL_ITERATOR -#pragma define PREC_STL_ITERATOR -#pragma link off global PREC_STL_ITERATOR; -#pragma link C++ nestedtypedef; -#pragma link C++ nestedclass; -#if defined(G__HP_aCC) || defined(G__SUNPRO_C) -#pragma mask_newdelete 0x1c; -#else -#pragma mask_newdelete 0x10; -#endif - -// Imported from STL HP implementation 1994 -// Imported from STL SGI implementation 1997 -// Imported from ANSI/ISO C++ draft Nov 1997 -// Modified by Masaharu Goto -// May need to improve for the latest standard - -#ifndef G__VISUAL -//////////////////////////////////////////////////////////////////////// -// iterator_tag -//////////////////////////////////////////////////////////////////////// -struct input_iterator_tag {}; -struct output_iterator_tag {}; -struct forward_iterator_tag {}; -struct bidirectional_iterator_tag {}; -struct random_access_iterator_tag {}; - -//////////////////////////////////////////////////////////////////////// -// iterator template -//////////////////////////////////////////////////////////////////////// -template <class T, class Distance> struct input_iterator {}; -struct output_iterator {}; -template <class T, class Distance> struct forward_iterator {}; -template <class T, class Distance> struct bidirectional_iterator {}; -template <class T, class Distance> struct random_access_iterator {}; -#else -struct output_iterator; -#endif - -//////////////////////////////////////////////////////////////////////// -// iterator_category overloaded function -//////////////////////////////////////////////////////////////////////// -template <class T, class Distance> -inline input_iterator_tag -iterator_category(const input_iterator<T, Distance>&) { - return input_iterator_tag(); -} - -inline output_iterator_tag iterator_category(const output_iterator&) { - return output_iterator_tag(); -} - -template <class T, class Distance> -inline forward_iterator_tag -iterator_category(const forward_iterator<T, Distance>&) { - return forward_iterator_tag(); -} - -template <class T, class Distance> -inline bidirectional_iterator_tag -iterator_category(const bidirectional_iterator<T, Distance>&) { - return bidirectional_iterator_tag(); -} - -template <class T, class Distance> -inline random_access_iterator_tag -iterator_category(const random_access_iterator<T, Distance>&) { - return random_access_iterator_tag(); -} - -template <class T> -inline random_access_iterator_tag -iterator_category(const T*) { - return random_access_iterator_tag(); -} - - -// iterator_traits, iterator and reverse_iterator template may not be -// needed for precompiled library interface - -//////////////////////////////////////////////////////////////////////// -// iterator_traits -//////////////////////////////////////////////////////////////////////// - -template <class Iterator> -struct iterator_traits { - typedef typename Iterator::iterator_category iterator_category; - typedef typename Iterator::value_type value_type; - typedef typename Iterator::difference_type difference_type; - typedef typename Iterator::pointer pointer; - typedef typename Iterator::reference reference; -}; - -// template partial specialization, implement in cint5.15.14 1587 -template <class T> -struct iterator_traits<T*> { - typedef random_access_iterator_tag iterator_category; - typedef T value_type; - typedef ptrdiff_t difference_type; - typedef T* pointer; - typedef T& reference; -}; - -// incomplete implementation in cint5.15.14 1587, need some fix -// iterator_traits<const int*> is changed as iterator_traits<const int* const> -// or something, but cint5.15.14 can not handle this well -template <class T> -struct iterator_traits<const T*> { - typedef random_access_iterator_tag iterator_category; - typedef T value_type; - typedef ptrdiff_t difference_type; - typedef const T* pointer; - typedef const T& reference; -}; - -//////////////////////////////////////////////////////////////////////// -// iterator -//////////////////////////////////////////////////////////////////////// -template<class Category, class T, class Distance = ptrdiff_t, - class Pointer = T*, class Reference = T&> -struct iterator { - typedef T value_type; - typedef Distance difference_type; - typedef Pointer pointer; - typedef Reference reference; - typedef Category iterator_category; -}; - - -//////////////////////////////////////////////////////////////////////// -// reverse_iterator -//////////////////////////////////////////////////////////////////////// -template <class Iterator> -class reverse_iterator -#if defined(G__KCC) - : public iterator<iterator_traits<Iterator>::iterator_category, - iterator_traits<Iterator>::value_type, - iterator_traits<Iterator>::difference_type, - iterator_traits<Iterator>::pointer, - iterator_traits<Iterator>::reference> -#endif -{ -#if 0 - protected: - Iterator current; -#endif - public: -#if defined(G__KCC) - typedef Iterator iterator_type; - typedef typename iterator_traits<Iterator>::difference_type difference_type; - typedef typename iterator_traits<Iterator>::reference reference; - typedef typename iterator_traits<Iterator>::pointer pointer; -#else - typedef Iterator::pointer pointer; - typedef Iterator::reference reference; - typedef ptrdiff_t difference_type; -#endif - - reverse_iterator(); - //reverse_iterator(Iterator x); -#if 0 - template <class U> reverse_iterator(const reverse_iterator<U>& u); -#endif - Iterator base() const; // explicit - reference operator*() const; - pointer operator->() const; - reverse_iterator& operator++(); - reverse_iterator operator++(int); - reverse_iterator& operator--(); - reverse_iterator operator--(int); - reverse_iterator operator+ (difference_type n) const; - reverse_iterator& operator+=(difference_type n); - reverse_iterator operator- (difference_type n) const; - reverse_iterator& operator-=(difference_type n); - reference operator[](difference_type n) const; -}; - -#if defined(G__BORLANDCC5) -template <class T> -class reverse_iterator<T*> { - public: - typedef random_access_iterator_tag iterator_category; - typedef T value_type; - typedef ptrdiff_t difference_type; - typedef T* pointer; - typedef T& reference; - reverse_iterator(); - //reverse_iterator(Iterator x); -#if 0 - template <class U> reverse_iterator(const reverse_iterator<U>& u); -#endif - //Iterator base() const; // explicit - reference operator*() const; - pointer operator->() const; - reverse_iterator& operator++(); - reverse_iterator operator++(int); - reverse_iterator& operator--(); - reverse_iterator operator--(int); - reverse_iterator operator+ (difference_type n) const; - reverse_iterator& operator+=(difference_type n); - reverse_iterator operator- (difference_type n) const; - reverse_iterator& operator-=(difference_type n); - reference operator[](difference_type n) const; -}; -#endif - -#ifdef G__VISUAL -// VC++5.0 has different symbol names - -//////////////////////////////////////////////////////////////////////// -// iterator_tag -//////////////////////////////////////////////////////////////////////// -struct input_iterator_tag {}; -struct output_iterator_tag {}; -struct forward_iterator_tag - : public input_iterator_tag {}; -struct bidirectional_iterator_tag - : public forward_iterator_tag {}; -struct random_access_iterator_tag - : public bidirectional_iterator_tag {}; - -//////////////////////////////////////////////////////////////////////// -// iterator template -//////////////////////////////////////////////////////////////////////// -template <class T, class Distance> struct input_iterator {}; -struct output_iterator {}; -template <class T, class Distance> struct forward_iterator {}; -template <class T, class Distance> struct _Bidit {}; -template <class T, class Distance> struct _Ranit {}; - -//////////////////////////////////////////////////////////////////////// -// _Iter_cat overloaded function -//////////////////////////////////////////////////////////////////////// -template <class T, class Distance> -inline input_iterator_tag -_Iter_cat(const input_iterator<T, Distance>&) { - return input_iterator_tag(); -} - -inline output_iterator_tag _Iter_cat(const output_iterator&) { - return output_iterator_tag(); -} - -template <class T, class Distance> -inline forward_iterator_tag -_Iter_cat(const forward_iterator<T, Distance>&) { - return forward_iterator_tag(); -} - -template <class T, class Distance> -inline bidirectional_iterator_tag -_Iter_cat(const _Bidit<T, Distance>&) { - return bidirectional_iterator_tag(); -} - -template <class T, class Distance> -inline random_access_iterator_tag -_Iter_cat(const _Ranit<T, Distance>&) { - return random_access_iterator_tag(); -} - -template <class T> -inline random_access_iterator_tag -_Iter_cat(const T*) { - return random_access_iterator_tag(); -} -#endif - -#if (G__GNUC>=3) && !defined(G__KCC) - -#if (G__GNUC_MINOR<1) -// for g++ 3.00 -//////////////////////////////////////////////////////////////////////// -// __normal_iterator -//////////////////////////////////////////////////////////////////////// -template<typename _Iterator, typename _Container> -class __normal_iterator - : public std::iterator<std::iterator_traits<_Iterator>::iterator_category, - std::iterator_traits<_Iterator>::value_type, - std::iterator_traits<_Iterator>::difference_type, - std::iterator_traits<_Iterator>::pointer, - std::iterator_traits<_Iterator>::reference> -{ - -public: - typedef __normal_iterator<_Iterator, _Container> normal_iterator_type; - typedef std::iterator_traits<_Iterator> __traits_type; - typedef typename _Iterator::iterator_category iterator_category; - typedef typename _Iterator::value_type value_type; - typedef typename _Iterator::difference_type difference_type; - typedef typename _Iterator::pointer pointer; - typedef typename _Iterator::reference reference; - - //typedef typename __traits_type::iterator_category iterator_category; - //typedef typename __traits_type::value_type value_type; - //typedef typename __traits_type::difference_type difference_type; - //typedef typename __traits_type::pointer pointer; - //typedef typename __traits_type::reference reference; - - __normal_iterator() ; - -#ifndef __CINT__ //this can be a problem, may need solution not to mask this - explicit __normal_iterator(const _Iterator& __i) ; -#endif - - // Allow iterator to const_iterator conversion - template<typename _Iter> - inline __normal_iterator(const __normal_iterator<_Iter, _Container>& __i); - - //There was a big hussle compiling operator*(), partial template - //specialization for iterator_traits<T*> used in __normal_iterator. - - // Forward iterator requirements - reference operator*() const ; - - pointer operator->() const ; - - normal_iterator_type& operator++() ; - - normal_iterator_type operator++(int) ; - - // Bidirectional iterator requirements - normal_iterator_type& operator--() ; - - normal_iterator_type operator--(int) ; - - // Random access iterator requirements - reference operator[](const difference_type& __n) const; - - normal_iterator_type& operator+=(const difference_type& __n); - - normal_iterator_type operator+(const difference_type& __n) const; - - normal_iterator_type& operator-=(const difference_type& __n); - - normal_iterator_type operator-(const difference_type& __n) const; - - difference_type operator-(const normal_iterator_type& __i) const; - - const _Iterator& base() const ; - - friend bool operator==(const __normal_iterator<_Iterator,_Container>&, - const __normal_iterator<_Iterator,_Container>&); - friend bool operator!=(const __normal_iterator<_Iterator,_Container>&, - const __normal_iterator<_Iterator,_Container>&); - friend bool operator<(const __normal_iterator<_Iterator,_Container>&, - const __normal_iterator<_Iterator,_Container>&); - friend bool operator>(const __normal_iterator<_Iterator,_Container>&, - const __normal_iterator<_Iterator,_Container>&); - friend bool operator<=(const __normal_iterator<_Iterator,_Container>&, - const __normal_iterator<_Iterator,_Container>&); - friend bool operator>=(const __normal_iterator<_Iterator,_Container>&, - const __normal_iterator<_Iterator,_Container>&); -}; - -// forward iterator requirements - -template<typename _IteratorL, typename _IteratorR, typename _Container> -inline bool -operator==(const __normal_iterator<_IteratorL, _Container>& __lhs, - const __normal_iterator<_IteratorR, _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); } - -// random access iterator requirements - -template<typename _IteratorL, typename _IteratorR, typename _Container> -inline bool -operator<(const __normal_iterator<_IteratorL, _Container>& __lhs, - const __normal_iterator<_IteratorR, _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; } - -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); } - -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); } - -template<typename _Iterator, typename _Container> -inline __normal_iterator<_Iterator, _Container> -operator+(__normal_iterator<_Iterator, _Container>::difference_type __n, - const __normal_iterator<_Iterator, _Container>& __i) -{ return __normal_iterator<_Iterator, _Container>(__i.base() + __n); } - -#else // (G__GNUC_MINOR>=1) - -#ifdef G__OLDIMPLEMENTATION1703 -// for g++ 3.1,3.2 -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 - // not a class, e.g. a pointer, into an iterator that is a class. - // 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, - typename iterator_traits<_Iterator>::value_type, - typename iterator_traits<_Iterator>::difference_type, - typename iterator_traits<_Iterator>::pointer, - typename iterator_traits<_Iterator>::reference> - { - protected: - _Iterator _M_current; - - public: - typedef typename iterator_traits<_Iterator>::difference_type - difference_type; - typedef typename iterator_traits<_Iterator>::reference reference; - typedef typename iterator_traits<_Iterator>::pointer pointer; - - __normal_iterator() : _M_current(_Iterator()) { } - - explicit - __normal_iterator(const _Iterator& __i) : _M_current(__i) { } - - // Allow iterator to const_iterator conversion - template<typename _Iter> - inline __normal_iterator(const __normal_iterator<_Iter, _Container>& __i) - : _M_current(__i.base()) { } - - // Forward iterator requirements - reference - operator*() const { return *_M_current; } - - pointer - operator->() const { return _M_current; } - - __normal_iterator& - operator++() { ++_M_current; return *this; } - - __normal_iterator - operator++(int) { return __normal_iterator(_M_current++); } - - // Bidirectional iterator requirements - __normal_iterator& - operator--() { --_M_current; return *this; } - - __normal_iterator - operator--(int) { return __normal_iterator(_M_current--); } - - // Random access iterator requirements - reference - operator[](const difference_type& __n) const - { return _M_current[__n]; } - - __normal_iterator& - operator+=(const difference_type& __n) - { _M_current += __n; return *this; } - - __normal_iterator - operator+(const difference_type& __n) const - { return __normal_iterator(_M_current + __n); } - - __normal_iterator& - operator-=(const difference_type& __n) - { _M_current -= __n; return *this; } - - __normal_iterator - operator-(const difference_type& __n) const - { return __normal_iterator(_M_current - __n); } - - const _Iterator& - 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 - operator==(const __normal_iterator<_IteratorL, _Container>& __lhs, - 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.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> - inline bool - operator<(const __normal_iterator<_IteratorL, _Container>& __lhs, - 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.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.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.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(); } - - // _GLIBCPP_RESOLVE_LIB_DEFECTS - // According to the resolution of DR179 not only the various comparison - // operators but also operator- must accept mixed iterator/const_iterator - // parameters. - template<typename _IteratorL, typename _IteratorR, typename _Container> - inline typename __normal_iterator<_IteratorL, _Container>::difference_type - operator-(const __normal_iterator<_IteratorL, _Container>& __lhs, - const __normal_iterator<_IteratorR, _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 __gnu_cxx -#endif - -#endif // G__GNUC_MINOR - - -#endif // G__GNUC>=3 - -#pragma endif +// lib/prec_stl/iterator + +#pragma ifndef PREC_STL_ITERATOR +#pragma define PREC_STL_ITERATOR +#pragma link off global PREC_STL_ITERATOR; +#pragma link C++ nestedtypedef; +#pragma link C++ nestedclass; +#if defined(G__HP_aCC) || defined(G__SUNPRO_C) +#pragma mask_newdelete 0x1c; +#else +#pragma mask_newdelete 0x10; +#endif + +// Imported from STL HP implementation 1994 +// Imported from STL SGI implementation 1997 +// Imported from ANSI/ISO C++ draft Nov 1997 +// Modified by Masaharu Goto +// May need to improve for the latest standard + +#ifndef G__VISUAL +//////////////////////////////////////////////////////////////////////// +// iterator_tag +//////////////////////////////////////////////////////////////////////// +struct input_iterator_tag {}; +struct output_iterator_tag {}; +struct forward_iterator_tag {}; +struct bidirectional_iterator_tag {}; +struct random_access_iterator_tag {}; + +//////////////////////////////////////////////////////////////////////// +// iterator template +//////////////////////////////////////////////////////////////////////// +template <class T, class Distance> struct input_iterator {}; +struct output_iterator {}; +template <class T, class Distance> struct forward_iterator {}; +template <class T, class Distance> struct bidirectional_iterator {}; +template <class T, class Distance> struct random_access_iterator {}; +#else +struct output_iterator; +#endif + +#if !(defined G__VISUAL && (G__MSC_VER>=1300)) + +//////////////////////////////////////////////////////////////////////// +// iterator_category overloaded function +//////////////////////////////////////////////////////////////////////// +template <class T, class Distance> +inline input_iterator_tag +iterator_category(const input_iterator<T, Distance>&) { + return input_iterator_tag(); +} + +inline output_iterator_tag iterator_category(const output_iterator&) { + return output_iterator_tag(); +} + +template <class T, class Distance> +inline forward_iterator_tag +iterator_category(const forward_iterator<T, Distance>&) { + return forward_iterator_tag(); +} + +template <class T, class Distance> +inline bidirectional_iterator_tag +iterator_category(const bidirectional_iterator<T, Distance>&) { + return bidirectional_iterator_tag(); +} + +template <class T, class Distance> +inline random_access_iterator_tag +iterator_category(const random_access_iterator<T, Distance>&) { + return random_access_iterator_tag(); +} + +template <class T> +inline random_access_iterator_tag +iterator_category(const T*) { + return random_access_iterator_tag(); +} + + +// iterator_traits, iterator and reverse_iterator template may not be +// needed for precompiled library interface + +//////////////////////////////////////////////////////////////////////// +// iterator_traits +//////////////////////////////////////////////////////////////////////// + +template <class Iterator> +struct iterator_traits { + typedef typename Iterator::iterator_category iterator_category; + typedef typename Iterator::value_type value_type; + typedef typename Iterator::difference_type difference_type; + typedef typename Iterator::pointer pointer; + typedef typename Iterator::reference reference; +}; + +// template partial specialization, implement in cint5.15.14 1587 +template <class T> +struct iterator_traits<T*> { + typedef random_access_iterator_tag iterator_category; + typedef T value_type; + typedef ptrdiff_t difference_type; + typedef T* pointer; + typedef T& reference; +}; + +// incomplete implementation in cint5.15.14 1587, need some fix +// iterator_traits<const int*> is changed as iterator_traits<const int* const> +// or something, but cint5.15.14 can not handle this well +template <class T> +struct iterator_traits<const T*> { + typedef random_access_iterator_tag iterator_category; + typedef T value_type; + typedef ptrdiff_t difference_type; + typedef const T* pointer; + typedef const T& reference; +}; + +//////////////////////////////////////////////////////////////////////// +// iterator +//////////////////////////////////////////////////////////////////////// +template<class Category, class T, class Distance = ptrdiff_t, + class Pointer = T*, class Reference = T&> +struct iterator { + typedef T value_type; + typedef Distance difference_type; + typedef Pointer pointer; + typedef Reference reference; + typedef Category iterator_category; +}; + + +//////////////////////////////////////////////////////////////////////// +// reverse_iterator +//////////////////////////////////////////////////////////////////////// +template <class Iterator> +class reverse_iterator +#if defined(G__KCC) + : public iterator<iterator_traits<Iterator>::iterator_category, + iterator_traits<Iterator>::value_type, + iterator_traits<Iterator>::difference_type, + iterator_traits<Iterator>::pointer, + iterator_traits<Iterator>::reference> +#endif +{ +#if 0 + protected: + Iterator current; +#endif + public: +#if defined(G__KCC) + typedef Iterator iterator_type; + typedef typename iterator_traits<Iterator>::difference_type difference_type; + typedef typename iterator_traits<Iterator>::reference reference; + typedef typename iterator_traits<Iterator>::pointer pointer; +#else + typedef Iterator::pointer pointer; + typedef Iterator::reference reference; + typedef ptrdiff_t difference_type; +#endif + + reverse_iterator(); + //reverse_iterator(Iterator x); +#if 0 + template <class U> reverse_iterator(const reverse_iterator<U>& u); +#endif + Iterator base() const; // explicit + reference operator*() const; + pointer operator->() const; + reverse_iterator& operator++(); + reverse_iterator operator++(int); + reverse_iterator& operator--(); + reverse_iterator operator--(int); + reverse_iterator operator+ (difference_type n) const; + reverse_iterator& operator+=(difference_type n); + reverse_iterator operator- (difference_type n) const; + reverse_iterator& operator-=(difference_type n); + reference operator[](difference_type n) const; +}; + +#if defined(G__BORLANDCC5) +template <class T> +class reverse_iterator<T*> { + public: + typedef random_access_iterator_tag iterator_category; + typedef T value_type; + typedef ptrdiff_t difference_type; + typedef T* pointer; + typedef T& reference; + reverse_iterator(); + //reverse_iterator(Iterator x); +#if 0 + template <class U> reverse_iterator(const reverse_iterator<U>& u); +#endif + //Iterator base() const; // explicit + reference operator*() const; + pointer operator->() const; + reverse_iterator& operator++(); + reverse_iterator operator++(int); + reverse_iterator& operator--(); + reverse_iterator operator--(int); + reverse_iterator operator+ (difference_type n) const; + reverse_iterator& operator+=(difference_type n); + reverse_iterator operator- (difference_type n) const; + reverse_iterator& operator-=(difference_type n); + reference operator[](difference_type n) const; +}; +#endif + +#endif + +#if defined(G__VISUAL) + +#if G__MSC_VER<1300 +// VC++5.0 has different symbol names for a few tags + +//////////////////////////////////////////////////////////////////////// +// iterator_tag +//////////////////////////////////////////////////////////////////////// +struct input_iterator_tag {}; +struct output_iterator_tag {}; +struct forward_iterator_tag + : public input_iterator_tag {}; +struct bidirectional_iterator_tag + : public forward_iterator_tag {}; +struct random_access_iterator_tag + : public bidirectional_iterator_tag {}; + +//////////////////////////////////////////////////////////////////////// +// iterator template +//////////////////////////////////////////////////////////////////////// +template <class T, class Distance> struct input_iterator {}; +struct output_iterator {}; +template <class T, class Distance> struct forward_iterator {}; +template <class T, class Distance> struct _Bidit {}; +template <class T, class Distance> struct _Ranit {}; + +//////////////////////////////////////////////////////////////////////// +// _Iter_cat overloaded function +//////////////////////////////////////////////////////////////////////// +template <class T, class Distance> +inline input_iterator_tag +_Iter_cat(const input_iterator<T, Distance>&) { + return input_iterator_tag(); +} + +inline output_iterator_tag _Iter_cat(const output_iterator&) { + return output_iterator_tag(); +} + +template <class T, class Distance> +inline forward_iterator_tag +_Iter_cat(const forward_iterator<T, Distance>&) { + return forward_iterator_tag(); +} + +template <class T, class Distance> +inline bidirectional_iterator_tag +_Iter_cat(const _Bidit<T, Distance>&) { + return bidirectional_iterator_tag(); +} + +template <class T, class Distance> +inline random_access_iterator_tag +_Iter_cat(const _Ranit<T, Distance>&) { + return random_access_iterator_tag(); +} + +template <class T> +inline random_access_iterator_tag +_Iter_cat(const T*) { + return random_access_iterator_tag(); +} + +#else // if G__MSC_VER>=1300 + +// Many of the MS C++ 7.x class have one additional +// typedef + +// ITERATOR TAGS +struct input_iterator_tag {}; +struct output_iterator_tag {}; +struct forward_iterator_tag : public input_iterator_tag {}; +struct bidirectional_iterator_tag : public forward_iterator_tag {}; +struct random_access_iterator_tag : public bidirectional_iterator_tag {}; + +struct _Int_iterator_tag {}; + +// POINTER ITERATOR TAGS +struct _Nonscalar_ptr_iterator_tag {}; +struct _Scalar_ptr_iterator_tag {}; + +// TEMPLATE CLASS iterator +template<class _Category, + class _Ty, + class _Diff = ptrdiff_t, + class _Pointer = _Ty *, + class _Reference = _Ty&> + struct iterator + { // base type for all iterator classes + typedef _Category iterator_category; + typedef _Ty value_type; + typedef _Diff difference_type; + typedef _Diff distance_type; // retained + typedef _Pointer pointer; + typedef _Reference reference; + }; + +template<class _Ty, + class _Diff, + class _Pointer, + class _Reference> + struct _Bidit + : public iterator<bidirectional_iterator_tag, _Ty, _Diff, + _Pointer, _Reference> + { // base for bidirectional iterators + }; + +template<class _Ty, + class _Diff, + class _Pointer, + class _Reference> + struct _Ranit + : public iterator<random_access_iterator_tag, _Ty, _Diff, + _Pointer, _Reference> + { // base for random-access iterators + }; + +struct _Outit + : public iterator<output_iterator_tag, void, void, + void, void> + { // base for output iterators + }; + +// TEMPLATE CLASS iterator_traits +template<class _Iter> + struct iterator_traits + { // get traits from iterator _Iter + typedef typename _Iter::iterator_category iterator_category; + typedef typename _Iter::value_type value_type; + typedef typename _Iter::difference_type difference_type; + typedef difference_type distance_type; // retained + typedef typename _Iter::pointer pointer; + typedef typename _Iter::reference reference; + }; + +template<class _Ty> + struct iterator_traits<_Ty *> + { // get traits from pointer + typedef random_access_iterator_tag iterator_category; + typedef _Ty value_type; + typedef ptrdiff_t difference_type; + typedef ptrdiff_t distance_type; // retained + typedef _Ty *pointer; + typedef _Ty& reference; + }; + +template<class _Ty> + struct iterator_traits<const _Ty *> + { // get traits from const pointer + typedef random_access_iterator_tag iterator_category; + typedef _Ty value_type; + typedef ptrdiff_t difference_type; + typedef ptrdiff_t distance_type; // retained + typedef const _Ty *pointer; + typedef const _Ty& reference; + }; + +template<> struct iterator_traits<_Bool> + { // get traits from integer type + typedef _Int_iterator_tag iterator_category; + }; + +template<> struct iterator_traits<char> + { // get traits from integer type + typedef _Int_iterator_tag iterator_category; + }; + +template<> struct iterator_traits<signed char> + { // get traits from integer type + typedef _Int_iterator_tag iterator_category; + }; + +template<> struct iterator_traits<unsigned char> + { // get traits from integer type + typedef _Int_iterator_tag iterator_category; + }; + + #ifdef _NATIVE_WCHAR_T_DEFINED +template<> struct iterator_traits<wchar_t> + { // get traits from integer type + typedef _Int_iterator_tag iterator_category; + }; + #endif /* _NATIVE_WCHAR_T_DEFINED */ + +template<> struct iterator_traits<short> + { // get traits from integer type + typedef _Int_iterator_tag iterator_category; + }; + +template<> struct iterator_traits<unsigned short> + { // get traits from integer type + typedef _Int_iterator_tag iterator_category; + }; + +template<> struct iterator_traits<int> + { // get traits from integer type + typedef _Int_iterator_tag iterator_category; + }; + +template<> struct iterator_traits<unsigned int> + { // get traits from integer type + typedef _Int_iterator_tag iterator_category; + }; + +template<> struct iterator_traits<long> + { // get traits from integer type + typedef _Int_iterator_tag iterator_category; + }; + +template<> struct iterator_traits<unsigned long> + { // get traits from integer type + typedef _Int_iterator_tag iterator_category; + }; + +#ifdef _LONGLONG +template<> struct iterator_traits<_LONGLONG> + { // get traits from integer type + typedef _Int_iterator_tag iterator_category; + }; + +template<> struct iterator_traits<_ULONGLONG> + { // get traits from integer type + typedef _Int_iterator_tag iterator_category; + }; +#endif /* _LONGLONG */ + + +// TEMPLATE CLASS reverse_iterator +template<class _RanIt> +class reverse_iterator + : public iterator<typename iterator_traits<_RanIt>::iterator_category, + typename iterator_traits<_RanIt>::value_type, + typename iterator_traits<_RanIt>::difference_type, + typename iterator_traits<_RanIt>::pointer, + typename iterator_traits<_RanIt>::reference> +{ // wrap iterator to run it backwards +public: + typedef reverse_iterator<_RanIt> _Myt; + typedef typename iterator_traits<_RanIt>::difference_type difference_type; + typedef typename iterator_traits<_RanIt>::pointer pointer; + typedef typename iterator_traits<_RanIt>::reference reference; + typedef _RanIt iterator_type; + + reverse_iterator(); + explicit reverse_iterator(_RanIt _Right); + // cint can't parse: + // template<class _Other> reverse_iterator(const reverse_iterator<_Other>& _Right); + + _RanIt base() const; + + reference operator*() const; + pointer operator->() const; + _Myt& operator++(); + _Myt operator++(int); + _Myt& operator--(); + _Myt operator--(int); + bool _Equal(const _Myt& _Right) const; + _Myt& operator+=(difference_type _Off); + _Myt operator+(difference_type _Off) const; + _Myt& operator-=(difference_type _Off); + _Myt operator-(difference_type _Off) const; + reference operator[](difference_type _Off) const; + bool _Less(const _Myt& _Right) const; + difference_type _Minus(const _Myt& _Right) const; + +protected: + + _RanIt current; // the wrapped iterator +}; + +// TEMPLATE CLASS reverse_bidirectional_iterator (retained) +template<class _BidIt, + class _Ty, + class _Reference = _Ty&, + class _Pointer = _Ty *, + class _Diff = ptrdiff_t> + class reverse_bidirectional_iterator + : public _Bidit<_Ty, _Diff, _Pointer, _Reference> + { // wrap bidirectional iterator to run it backwards +public: + typedef reverse_bidirectional_iterator<_BidIt, _Ty, _Reference, + _Pointer, _Diff> _Myt; + typedef _BidIt iterator_type; + + reverse_bidirectional_iterator(); + explicit reverse_bidirectional_iterator(_BidIt _Right); + _BidIt base() const; + _Reference operator*() const; + _Pointer operator->() const; + _Myt& operator++(); + _Myt operator++(int); + _Myt& operator--(); + _Myt operator--(int); + bool operator==(const _Myt& _Right) const; + bool operator!=(const _Myt& _Right) const; + +protected: + // _BidIt current; // the wrapped iterator + }; + +// TEMPLATE CLASS _Revbidit +template<class _BidIt, + class _BidIt2 = _BidIt> + class _Revbidit + : public iterator< + typename iterator_traits<_BidIt>::iterator_category, + typename iterator_traits<_BidIt>::value_type, + typename iterator_traits<_BidIt>::difference_type, + typename iterator_traits<_BidIt>::pointer, + typename iterator_traits<_BidIt>::reference> + { // wrap bidirectional iterator to run it backwards +public: + typedef _Revbidit<_BidIt, _BidIt2> _Myt; + typedef typename iterator_traits<_BidIt>::difference_type _Diff; + typedef typename iterator_traits<_BidIt>::pointer _Pointer; + typedef typename iterator_traits<_BidIt>::reference _Reference; + typedef _BidIt iterator_type; + + _Revbidit(); + explicit _Revbidit(_BidIt _Right); + _Revbidit(const _Revbidit<_BidIt2>& _Other); + _BidIt base() const; + _Reference operator*() const; + _Pointer operator->() const; + _Myt& operator++(); + _Myt operator++(int); + _Myt& operator--(); + _Myt operator--(int); + bool operator==(const _Myt& _Right) const; + bool operator!=(const _Myt& _Right) const; + +protected: + //_BidIt current; + }; + +// TEMPLATE CLASS istreambuf_iterator +template<class _Elem, + class _Traits> + class istreambuf_iterator + : public iterator<input_iterator_tag, + _Elem, typename _Traits::off_type, _Elem *, _Elem&> + { // wrap stream buffer as input iterator +public: + typedef istreambuf_iterator<_Elem, _Traits> _Myt; + typedef _Elem char_type; + typedef _Traits traits_type; + typedef basic_streambuf<_Elem, _Traits> streambuf_type; + typedef basic_istream<_Elem, _Traits> istream_type; + typedef typename traits_type::int_type int_type; + + istreambuf_iterator(streambuf_type *_Sb = 0) _THROW0(); + istreambuf_iterator(istream_type& _Istr) _THROW0(); + _Elem operator*() const; + _Myt& operator++(); + _Myt operator++(int); + bool equal(const _Myt& _Right) const; + +private: + void _Inc() + _Elem _Peek() + streambuf_type *_Strbuf; // the wrapped stream buffer + bool _Got; // true if _Val is valid + _Elem _Val; // next element to deliver + }; + + +// TEMPLATE CLASS ostreambuf_iterator +template<class _Elem, + class _Traits> + class ostreambuf_iterator + : public _Outit + { // wrap stream buffer as output iterator + typedef ostreambuf_iterator<_Elem, _Traits> _Myt; +public: + typedef _Elem char_type; + typedef _Traits traits_type; + typedef basic_streambuf<_Elem, _Traits> streambuf_type; + typedef basic_ostream<_Elem, _Traits> ostream_type; + + ostreambuf_iterator(streambuf_type *_Sb) _THROW0(); + ostreambuf_iterator(ostream_type& _Ostr) _THROW0(); + _Myt& operator=(_Elem _Right); + _Myt& operator*(); + _Myt& operator++(); + _Myt& operator++(int); + bool failed() const _THROW0(); +private: + bool _Failed; // true if any stores have failed + streambuf_type *_Strbuf; // the wrapped stream buffer + }; + +template<class _Category, + class _Ty, + class _Diff = ptrdiff_t, + class _Pointer = _Ty *, + class _Reference = _Ty&> + struct iterator + { // base type for all iterator classes + typedef _Category iterator_category; + typedef _Ty value_type; + typedef _Diff difference_type; + typedef _Diff distance_type; // retained + typedef _Pointer pointer; + typedef _Reference reference; + }; + +#endif + +#endif + + +#if (G__GNUC>=3) && !defined(G__KCC) + +#if (G__GNUC_MINOR<1) +// for g++ 3.00 +//////////////////////////////////////////////////////////////////////// +// __normal_iterator +//////////////////////////////////////////////////////////////////////// +template<typename _Iterator, typename _Container> +class __normal_iterator + : public std::iterator<std::iterator_traits<_Iterator>::iterator_category, + std::iterator_traits<_Iterator>::value_type, + std::iterator_traits<_Iterator>::difference_type, + std::iterator_traits<_Iterator>::pointer, + std::iterator_traits<_Iterator>::reference> +{ + +public: + typedef __normal_iterator<_Iterator, _Container> normal_iterator_type; + typedef std::iterator_traits<_Iterator> __traits_type; + typedef typename _Iterator::iterator_category iterator_category; + typedef typename _Iterator::value_type value_type; + typedef typename _Iterator::difference_type difference_type; + typedef typename _Iterator::pointer pointer; + typedef typename _Iterator::reference reference; + + //typedef typename __traits_type::iterator_category iterator_category; + //typedef typename __traits_type::value_type value_type; + //typedef typename __traits_type::difference_type difference_type; + //typedef typename __traits_type::pointer pointer; + //typedef typename __traits_type::reference reference; + + __normal_iterator() ; + +#ifndef __CINT__ //this can be a problem, may need solution not to mask this + explicit __normal_iterator(const _Iterator& __i) ; +#endif + + // Allow iterator to const_iterator conversion + template<typename _Iter> + inline __normal_iterator(const __normal_iterator<_Iter, _Container>& __i); + + //There was a big hussle compiling operator*(), partial template + //specialization for iterator_traits<T*> used in __normal_iterator. + + // Forward iterator requirements + reference operator*() const ; + + pointer operator->() const ; + + normal_iterator_type& operator++() ; + + normal_iterator_type operator++(int) ; + + // Bidirectional iterator requirements + normal_iterator_type& operator--() ; + + normal_iterator_type operator--(int) ; + + // Random access iterator requirements + reference operator[](const difference_type& __n) const; + + normal_iterator_type& operator+=(const difference_type& __n); + + normal_iterator_type operator+(const difference_type& __n) const; + + normal_iterator_type& operator-=(const difference_type& __n); + + normal_iterator_type operator-(const difference_type& __n) const; + + difference_type operator-(const normal_iterator_type& __i) const; + + const _Iterator& base() const ; + + friend bool operator==(const __normal_iterator<_Iterator,_Container>&, + const __normal_iterator<_Iterator,_Container>&); + friend bool operator!=(const __normal_iterator<_Iterator,_Container>&, + const __normal_iterator<_Iterator,_Container>&); + friend bool operator<(const __normal_iterator<_Iterator,_Container>&, + const __normal_iterator<_Iterator,_Container>&); + friend bool operator>(const __normal_iterator<_Iterator,_Container>&, + const __normal_iterator<_Iterator,_Container>&); + friend bool operator<=(const __normal_iterator<_Iterator,_Container>&, + const __normal_iterator<_Iterator,_Container>&); + friend bool operator>=(const __normal_iterator<_Iterator,_Container>&, + const __normal_iterator<_Iterator,_Container>&); +}; + +// forward iterator requirements + +template<typename _IteratorL, typename _IteratorR, typename _Container> +inline bool +operator==(const __normal_iterator<_IteratorL, _Container>& __lhs, + const __normal_iterator<_IteratorR, _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); } + +// random access iterator requirements + +template<typename _IteratorL, typename _IteratorR, typename _Container> +inline bool +operator<(const __normal_iterator<_IteratorL, _Container>& __lhs, + const __normal_iterator<_IteratorR, _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; } + +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); } + +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); } + +template<typename _Iterator, typename _Container> +inline __normal_iterator<_Iterator, _Container> +operator+(__normal_iterator<_Iterator, _Container>::difference_type __n, + const __normal_iterator<_Iterator, _Container>& __i) +{ return __normal_iterator<_Iterator, _Container>(__i.base() + __n); } + +#else // (G__GNUC_MINOR>=1) + +#ifdef G__OLDIMPLEMENTATION1703 +// for g++ 3.1,3.2 +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 + // not a class, e.g. a pointer, into an iterator that is a class. + // 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, + typename iterator_traits<_Iterator>::value_type, + typename iterator_traits<_Iterator>::difference_type, + typename iterator_traits<_Iterator>::pointer, + typename iterator_traits<_Iterator>::reference> + { + protected: + _Iterator _M_current; + + public: + typedef typename iterator_traits<_Iterator>::difference_type + difference_type; + typedef typename iterator_traits<_Iterator>::reference reference; + typedef typename iterator_traits<_Iterator>::pointer pointer; + + __normal_iterator() : _M_current(_Iterator()) { } + + explicit + __normal_iterator(const _Iterator& __i) : _M_current(__i) { } + + // Allow iterator to const_iterator conversion + template<typename _Iter> + inline __normal_iterator(const __normal_iterator<_Iter, _Container>& __i) + : _M_current(__i.base()) { } + + // Forward iterator requirements + reference + operator*() const { return *_M_current; } + + pointer + operator->() const { return _M_current; } + + __normal_iterator& + operator++() { ++_M_current; return *this; } + + __normal_iterator + operator++(int) { return __normal_iterator(_M_current++); } + + // Bidirectional iterator requirements + __normal_iterator& + operator--() { --_M_current; return *this; } + + __normal_iterator + operator--(int) { return __normal_iterator(_M_current--); } + + // Random access iterator requirements + reference + operator[](const difference_type& __n) const + { return _M_current[__n]; } + + __normal_iterator& + operator+=(const difference_type& __n) + { _M_current += __n; return *this; } + + __normal_iterator + operator+(const difference_type& __n) const + { return __normal_iterator(_M_current + __n); } + + __normal_iterator& + operator-=(const difference_type& __n) + { _M_current -= __n; return *this; } + + __normal_iterator + operator-(const difference_type& __n) const + { return __normal_iterator(_M_current - __n); } + + const _Iterator& + 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 + operator==(const __normal_iterator<_IteratorL, _Container>& __lhs, + 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.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> + inline bool + operator<(const __normal_iterator<_IteratorL, _Container>& __lhs, + 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.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.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.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(); } + + // _GLIBCPP_RESOLVE_LIB_DEFECTS + // According to the resolution of DR179 not only the various comparison + // operators but also operator- must accept mixed iterator/const_iterator + // parameters. + template<typename _IteratorL, typename _IteratorR, typename _Container> + inline typename __normal_iterator<_IteratorL, _Container>::difference_type + operator-(const __normal_iterator<_IteratorL, _Container>& __lhs, + const __normal_iterator<_IteratorR, _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 __gnu_cxx +#endif + +#endif // G__GNUC_MINOR + + +#endif // G__GNUC>=3 + +#pragma endif diff --git a/cint/lib/prec_stl/vector b/cint/lib/prec_stl/vector index be7c626a8a2..da20bf06ab7 100644 --- a/cint/lib/prec_stl/vector +++ b/cint/lib/prec_stl/vector @@ -1,452 +1,534 @@ -// lib/prec_stl/vector - -#pragma ifndef PREC_STL_VECTOR -#pragma define PREC_STL_VECTOR -#pragma link off global PREC_STL_VECTOR; -#pragma link C++ nestedtypedef; -#pragma link C++ nestedclass; -#if defined(G__HP_aCC) || defined(G__SUNPRO_C) -#pragma mask_newdelete 0x1c; -#else -#pragma mask_newdelete 0x10; -#endif - -// Imported from ANSI/ISO C++ 1997/Nov draft -// Got some ideas from Scott Snyder, Fermi-lab -// Modified by Masaharu Goto -// SGI KCC porting by Philippe Canal, Fermi-lab - -#include <_iterator> -#include <_memory> -#include <_utility> - -#if defined(G__AIX) -template<class _Ty, class _D, class _Pt, class _Rt, - class _Pt2, class _Rt2> - class _Ptrit; -#endif - -#if defined(G__ANSIISOLIB) || (G__GNUC>=3) -template<class T,class Allocator=std::allocator<T> > -#elif defined(G__GNUC) && !defined(G__KCC) -#if (G__GNUC_MINOR>=95) -template<class T,class Allocator=allocator<T> > -#else -template<class T,class Allocator=alloc> -#endif -#elif defined(G__HPUX) -template<class T,class Allocator=allocator> -#else -template<class T,class Allocator=std::allocator<T> > -#endif -class vector { - public: - typedef T value_type; - -#if ((defined(G__GNUC) || defined(G__SGI)) && !defined(G__KCC)) || defined(G__HPUX) - typedef value_type* pointer; - typedef const value_type* const_pointer; - typedef value_type& reference; - typedef const value_type& const_reference; - typedef size_t size_type; - typedef ptrdiff_t difference_type; -#else - typedef typename Allocator::pointer pointer; - typedef typename Allocator::const_pointer const_pointer; - typedef typename Allocator::reference reference; - typedef typename Allocator::const_reference const_reference; - typedef typename Allocator::size_type size_type; - typedef typename Allocator::difference_type difference_type; -#endif - -#if defined(G__KCC) - typedef typename Allocator::pointer iterator; - typedef typename Allocator::const_pointer const_iterator; - typedef Allocator allocator_type; - typedef reverse_iterator<iterator> reverse_iterator; - typedef reverse_iterator<const_iterator> const_reverse_iterator; - -#elif defined(G__AIX) - - typedef Allocator allocator_type; - typedef _Ptrit<value_type, difference_type, pointer, - reference, pointer, reference> iterator; - typedef _Ptrit<value_type, difference_type, const_pointer, - const_reference, pointer, reference> const_iterator; - //class iterator; - //class const_iterator; - typedef typename std::reverse_iterator<iterator> reverse_iterator; - typedef typename std::reverse_iterator<const_iterator> const_reverse_iterator; - -#elif (G__GNUC>=3 && G__GNUC_MINOR>=1) - -#ifndef G__OLDIMPLEMENTATION1703 - class iterator { - public: - iterator(); - explicit iterator(const pointer& __i) ; - // Allow iterator to const_iterator conversion - template<typename _Iter> inline iterator(const iterator& __i); - - // Forward iterator requirements - reference operator*() const ; - pointer operator->() const ; - iterator& operator++(); - iterator operator++(int) ; - - // Bidirectional iterator requirements - iterator& operator--() ; - iterator operator--(int) ; - - // Random access iterator requirements - reference operator[](const difference_type& __n) const; - iterator& operator+=(const difference_type& __n); - iterator operator+(const difference_type& __n) const; - iterator& operator-=(const difference_type& __n); - iterator operator-(const difference_type& __n) const; - const pointer& base() const ; - }; - friend bool operator==(const vector::iterator& x,const vector::iterator& y)const; - friend bool operator!=(const vector::iterator& x,const vector::iterator& y)const; - friend bool operator<(const vector::iterator& x,const vector::iterator& y)const; - friend bool operator>(const vector::iterator& x,const vector::iterator& y)const; - friend bool operator<=(const vector::iterator& x,const vector::iterator& y)const; - friend bool operator>=(const vector::iterator& x,const vector::iterator& y)const; - friend vector::iterator::difference_type operator-(const vector::iterator& x,const vector::iterator& y)const; - friend vector::iterator operator+(const vector::iterator::difference_type x,const vector::iterator& y)const; - typedef const iterator const_iterator; -#else /* 1703 */ - typedef vector<T, Allocator> vector_type; - typedef __gnu_cxx::__normal_iterator<pointer, vector_type> iterator; - typedef __gnu_cxx::__normal_iterator<const_pointer, vector_type> - const_iterator; -#endif /* 1703 */ - -#elif (G__GNUC>=3 && G__GNUC_MINOR==0) - typedef vector<T, Allocator> vector_type; - typedef std::__normal_iterator<T*, vector_type> iterator; - typedef std::__normal_iterator<T*, vector_type> const_iterator; -#else - typedef T* iterator; - typedef const T* const_iterator; -#endif - - -#if defined(G__BORLANDCC5) - typedef reverse_iterator<iterator> reverse_iterator; -#elif (G__GNUC>=3 && G__GNUC_MINOR>=1) || defined(G__AIX) - typedef reverse_iterator<const_iterator> const_reverse_iterator; - typedef reverse_iterator<iterator> reverse_iterator; -#else // G__BORLANDCC5 -#if defined(G__KCC) && 0 - //There is a bug in the CINT parsing of #if between the 'class X' and the body of the class - //declaration. so for now we keep this dummy test ... - // typedef reverse_iterator<iterator> reverse_iterator; -#else - class reverse_iterator -#if defined(G__VISUAL) - : public _Ranit<T,difference_type> -#elif !defined(G__SUNPRO_C) && !defined(G__INTEL_COMPILER) && !defined(G__KCC) && !defined(G__AIX) && !defined(G__ALPHA) - : public std::random_access_iterator<T,difference_type> -#endif - { - public: - reverse_iterator(const reverse_iterator& x) ; -#if !defined(G__BORLAND) && !defined(G__KCC) && !(defined (G__SGI)&&!defined(G__GNU)) && !defined(G__ALPHA) - reverse_iterator& operator=(const reverse_iterator& x) ; -#endif -#if !(G__GNUC>=3) && !defined(G__KCC) - T* base() ; -#else - iterator base() ; -#endif - T& operator*() const ; - reverse_iterator& operator++(); - reverse_iterator operator++(int a); - reverse_iterator& operator--(); - reverse_iterator operator--(int a); - reverse_iterator operator+(long n); - reverse_iterator operator-(long n); - reverse_iterator& operator+=(long n); - reverse_iterator& operator-=(long n); - T& operator[](long n) ; - private: - }; -#endif -#endif // G__BORLANDCC5 - friend bool operator==(const vector::reverse_iterator& x - ,const vector::reverse_iterator& y) const; - friend bool operator!=(const vector::reverse_iterator& x - ,const vector::reverse_iterator& y) const; - -#if !(G__GNUC>=3 && G__GNUC_MINOR>=1) - typedef const reverse_iterator const_reverse_iterator; -#endif - -#if (G__GNUC>=3) && !defined(G__KCC) - friend bool operator==(vector::const_iterator& x - ,vector::const_iterator& y) const; - friend bool operator!=(vector::const_iterator& x - ,vector::const_iterator& y) const; -#endif - -#if 0 - friend random_access_iterator_tag - iterator_category(random_access_iterator<T,vector::difference_type>& x); - //friend random_access_iterator_tag - //iterator_category(vector::reverse_iterator& x); -#endif - - iterator begin(void) ; - iterator end(void) ; - reverse_iterator rbegin(void) ; - reverse_iterator rend(void) ; -#ifdef G__CONSTNESSFLAG - const_iterator begin(void) const; - const_iterator end(void) const; - const_reverse_iterator rbegin(void) const; - const_reverse_iterator rend(void) const; -#endif - size_type size(void) const ; - size_type max_size(void) const ; - size_type capacity(void) const ; - bool empty(void) const ; - T& operator[](size_type n) ; - vector(void) ; - vector(size_type n,const T& value=T()) ; - vector(const vector& x) ; - vector(const_iterator first,const_iterator last) ; - ~vector(void) ; - vector& operator=(const vector& x); - void reserve(size_type n) ; - T& front(void) ; - T& back(void) ; - void push_back(const T& x) ; - void swap(vector& x); - iterator insert(iterator position,const T& x); - void insert(iterator position,const_iterator first,const_iterator last); - void insert(iterator position,size_type n,const T& x); - void pop_back(void) ; - void erase(iterator position) ; - void erase(iterator first,iterator last) ; - void clear() ; - -#if (G__GNUC>=3) || defined(G__KCC) - // doesn't work on VC++ 5.0 - friend bool operator==(const vector& x, const vector& y); - friend bool operator< (const vector& x, const vector& y); - friend bool operator!=(const vector& x, const vector& y); - friend bool operator> (const vector& x, const vector& y); - friend bool operator>=(const vector& x, const vector& y); - friend bool operator<=(const vector& x, const vector& y); -#endif - // specialized algorithms: -#if !defined(G__GNUC) || defined(G__KCC) - // doesn't work on egcs - friend void swap(vector& x, vector& y); -#endif - - -#ifndef G__NOALGORITHM - - // Generic algorithm -#if defined(G__GNUC) || defined(G__BORLAND) || defined(G__KCC) - - // input iter - friend vector::iterator - find(vector::iterator first,vector::iterator last,const T& value); - // forward iter - friend vector::iterator - find_end(vector::iterator first1,vector::iterator last1, - vector::iterator first2,vector::iterator last2); - friend vector::iterator - find_first_of(vector::iterator first1,vector::iterator last1, - vector::iterator first2,vector::iterator last2); - friend vector::iterator - adjacent_find(vector::iterator first,vector::iterator last); - // input iter -#if !defined(G__BORLAND) - friend vector::difference_type - count(vector::iterator first,vector::iterator last,const T& value); -#endif -#if 0 - friend pair<vector::iterator,vector::iterator> - mismatch(vector::iterator first1,vector::iterator last1, - vector::iterator first2); -#endif - friend bool - equal(vector::iterator first1,vector::iterator last1, - vector::iterator first2); - // forward iter - friend vector::iterator - search(vector::iterator first1,vector::iterator last1, - vector::iterator first2,vector::iterator last2); - friend vector::iterator - search_n(vector::iterator first,vector::iterator last - ,vector::size_type count,const T& value); - // input and output iter -> forward iter - friend vector::iterator - copy(vector::iterator first,vector::iterator last, - vector::iterator result); - // bidirectional iter - friend vector::iterator - copy_backward(vector::iterator first,vector::iterator last, - vector::iterator result); - // just value_type - friend void swap(T& a,T& b); - // forward iter - friend vector::iterator - swap_ranges(vector::iterator first1,vector::iterator last1, - vector::iterator first2); - friend void iter_swap(vector::iterator a,vector::iterator b); - friend void replace(vector::iterator first,vector::iterator last, - const T& old_value,const T& new_value); - // input, output iter -> forward iter - friend vector::iterator - replace_copy(vector::iterator first,vector::iterator last, - vector::iterator result, - const T& old_value,const T& new_value); - // forward iter - friend void - fill(vector::iterator first,vector::iterator last,const T& value); -#if (G__GNUC>=3) || defined(G__KCC) - friend void - fill_n(vector::iterator first,vector::size_type n,const T& value); -#endif - friend vector::iterator - remove(vector::iterator first,vector::iterator last,const T& value); - // input,output iter -> forward iter - friend vector::iterator - remove_copy(vector::iterator first,vector::iterator last, - vector::iterator result,const T& value); - friend vector::iterator - unique(vector::iterator first,vector::iterator last); - friend vector::iterator - unique_copy(vector::iterator first,vector::iterator last, - vector::iterator result); - friend void reverse(vector::iterator first,vector::iterator last); - friend vector::iterator - reverse_copy(vector::iterator first,vector::iterator last, - vector::iterator result); - // forward iter -#if (G__GNUC>=3) || defined(G__KCC) - friend void rotate(vector::iterator first,vector::iterator mid, - vector::iterator last); -#endif - // forward iter - friend vector::iterator - rotate_copy(vector::iterator first,vector::iterator mid, - vector::iterator last,vector::iterator result); - // randomaccess iter - friend void random_shuffle(vector::iterator first,vector::iterator last); - // randomaccess iter - friend void sort(vector::iterator first,vector::iterator last); - friend void stable_sort(vector::iterator first,vector::iterator last); - friend void partial_sort(vector::iterator first,vector::iterator mid, - vector::iterator last); - friend vector::iterator - partial_sort_copy(vector::iterator first,vector::iterator last, - vector::iterator result_first, - vector::iterator result_last); - friend void nth_element(vector::iterator first,vector::iterator nth, - vector::iterator last); - // forward iter - friend vector::iterator - lower_bound(vector::iterator first,vector::iterator last,const T& value); - friend vector::iterator - upper_bound(vector::iterator first,vector::iterator last,const T& value); -#if 0 - friend pair<vector::iterator,vector::iterator> - equal_range(vector::iterator first,vector::iterator last,const T& value); -#endif - friend bool binary_search(vector::iterator first,vector::iterator last, - const T& value); - friend vector::iterator merge(vector::iterator first1,vector::iterator last1, - vector::iterator first2,vector::iterator last2, - vector::iterator result); - friend void inplace_merge(vector::iterator first,vector::iterator middle, - vector::iterator last); - friend bool includes(vector::iterator first1,vector::iterator last1, - vector::iterator first2,vector::iterator last2); - friend vector::iterator - set_union(vector::iterator first1,vector::iterator last1, - vector::iterator first2,vector::iterator last2, - vector::iterator result); - friend vector::iterator - set_intersection(vector::iterator first1,vector::iterator last1, - vector::iterator first2,vector::iterator last2, - vector::iterator result); - friend vector::iterator - set_difference(vector::iterator first1,vector::iterator last1, - vector::iterator first2,vector::iterator last2, - vector::iterator result); - friend vector::iterator - set_symmetric_difference(vector::iterator first1,vector::iterator last1, - vector::iterator first2,vector::iterator last2, - vector::iterator result); - // random access - friend void push_heap(vector::iterator first,vector::iterator last); - friend void pop_heap(vector::iterator first,vector::iterator last); - friend void make_heap(vector::iterator first,vector::iterator last); - friend void sort_heap(vector::iterator first,vector::iterator last); - // min,max, just value_type - friend const T& min(const T& a,const T& b); - friend const T& max(const T& a,const T& b); - // forward iter - friend vector::iterator - min_element(vector::iterator first,vector::iterator last); - friend vector::iterator - max_element(vector::iterator first,vector::iterator last); - // input iter - friend bool - lexicographical_compare(vector::iterator first1,vector::iterator last1, - vector::iterator first2,vector::iterator last2); - // bidirectional iter - friend bool next_permutation(vector::iterator first,vector::iterator last); - friend bool prev_permutation(vector::iterator first,vector::iterator last); - -#elif defined(G__VISUAL) - - friend void reverse(vector::iterator first,vector::iterator last); - friend void sort(vector::iterator first,vector::iterator last); - - friend vector::iterator - find(vector::iterator first,vector::iterator last,const T& value); - friend vector::iterator - search(vector::iterator first1,vector::iterator last1, - vector::iterator first2,vector::iterator last2); - friend vector::iterator - copy(vector::iterator first,vector::iterator last, - vector::iterator result); - friend void - fill(vector::iterator first,vector::iterator last,const T& value); -#if 0 - // this is the limit that VC++ can handle - friend vector::iterator - remove(vector::iterator first,vector::iterator last,const T& value); - friend vector::iterator - unique(vector::iterator first,vector::iterator last); -#endif - -#endif // G__VISUAL,G__GNUC,G__BORLAND - -#endif // G__NOALGORITHM - - // iterator_category resolution - //friend random_access_iterator_tag iterator_category(vector::iterator x); - -}; - -#if 0 // G__defined("std::vector<bool>") -#pragma link off class std::vector<bool>::iterator; -#pragma link off function operator==(std::vector<bool>::iterator&,std::vector<bool>::iterator&); -#pragma link off function operator!=(std::vector<bool>::iterator&,std::vector<bool>::iterator&); -#pragma link off function operator<(std::vector<bool>::iterator&,std::vector<bool>::iterator&); -#pragma link off function operator>(std::vector<bool>::iterator&,std::vector<bool>::iterator&); -#pragma link off function operator<=(std::vector<bool>::iterator&,std::vector<bool>::iterator&); -#pragma link off function operator>=(std::vector<bool>::iterator&,std::vector<bool>::iterator&); -#endif - - - -#pragma endif +// lib/prec_stl/vector + +#pragma ifndef PREC_STL_VECTOR +#pragma define PREC_STL_VECTOR +#pragma link off global PREC_STL_VECTOR; +#pragma link C++ nestedtypedef; +#pragma link C++ nestedclass; +#if defined(G__HP_aCC) || defined(G__SUNPRO_C) +#pragma mask_newdelete 0x1c; +#else +#pragma mask_newdelete 0x10; +#endif + +// Imported from ANSI/ISO C++ 1997/Nov draft +// Got some ideas from Scott Snyder, Fermi-lab +// Modified by Masaharu Goto +// SGI KCC porting by Philippe Canal, Fermi-lab + +#include <_iterator> +#include <_memory> +#include <_utility> + +#if defined(G__AIX) +template<class _Ty, class _D, class _Pt, class _Rt, + class _Pt2, class _Rt2> + class _Ptrit; +#endif + +#if defined(G__ANSIISOLIB) || (G__GNUC>=3) +template<class T,class Allocator=std::allocator<T> > +#elif defined(G__GNUC) && !defined(G__KCC) +#if (G__GNUC_MINOR>=95) +template<class T,class Allocator=allocator<T> > +#else +template<class T,class Allocator=alloc> +#endif +#elif defined(G__HPUX) +template<class T,class Allocator=allocator> +#else +template<class T,class Allocator=std::allocator<T> > +#endif +class vector { + public: + typedef T value_type; + +#if ((defined(G__GNUC) || defined(G__SGI)) && !defined(G__KCC)) || defined(G__HPUX) + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type& reference; + typedef const value_type& const_reference; + typedef size_t size_type; + typedef ptrdiff_t difference_type; +#else + typedef typename Allocator::pointer pointer; + typedef typename Allocator::const_pointer const_pointer; + typedef typename Allocator::reference reference; + typedef typename Allocator::const_reference const_reference; + typedef typename Allocator::size_type size_type; + typedef typename Allocator::difference_type difference_type; +#endif + +#if defined(G__KCC) + typedef typename Allocator::pointer iterator; + typedef typename Allocator::const_pointer const_iterator; + typedef Allocator allocator_type; + typedef reverse_iterator<iterator> reverse_iterator; + typedef reverse_iterator<const_iterator> const_reverse_iterator; + +#elif defined(G__AIX) + + typedef Allocator allocator_type; + typedef _Ptrit<value_type, difference_type, pointer, + reference, pointer, reference> iterator; + typedef _Ptrit<value_type, difference_type, const_pointer, + const_reference, pointer, reference> const_iterator; + //class iterator; + //class const_iterator; + typedef typename std::reverse_iterator<iterator> reverse_iterator; + typedef typename std::reverse_iterator<const_iterator> const_reverse_iterator; + +#elif defined(G__VISUAL) && (G__MSC_VER>=1300) + + // CLASS const_iterator + class const_iterator; + friend class const_iterator; + + class const_iterator + : public _Ranit<T, difference_type, const_pointer, const_reference> + { // iterator for nonmutable vector + public: + typedef random_access_iterator_tag iterator_category; + typedef T value_type; + typedef Allocator::difference_type difference_type; + typedef const_pointer pointer; + typedef const_reference reference; + + const_iterator(); + const_iterator(pointer _Ptr); + + const_reference operator*() const; + + + const_pointer operator->() const; + const_iterator& operator++(); + const_iterator operator++(int); + const_iterator& operator--(); + const_iterator operator--(int); + const_iterator& operator+=(difference_type _Off); + const_iterator operator+(difference_type _Off) const; + const_iterator& operator-=(difference_type _Off); + const_iterator operator-(difference_type _Off) const; + difference_type operator-(const const_iterator& _Right) const; + const_reference operator[](difference_type _Off) const; + bool operator==(const const_iterator& _Right) const; + bool operator!=(const const_iterator& _Right) const; + bool operator<(const const_iterator& _Right) const; + bool operator>(const const_iterator& _Right) const; + bool operator<=(const const_iterator& _Right) const; + bool operator>=(const const_iterator& _Right) const; + friend const_iterator operator+(difference_type _Off, + const const_iterator& _Right); + pointer _Myptr; // offset of element in vector + }; + + // CLASS iterator + class iterator; + friend class iterator; + + class iterator + : public const_iterator + { // iterator for mutable vector + public: + typedef random_access_iterator_tag iterator_category; + typedef T value_type; + typedef Allocator::diffrence_type difference_type; + typedef Allocator::pointer pointer; + typedef Allocator::reference reference; + + iterator(); + iterator(pointer _Ptr); + reference operator*() const; + pointer operator->() const; + iterator& operator++(); + iterator operator++(int); + iterator& operator--(); + iterator operator--(int); + iterator& operator+=(difference_type _Off); + iterator operator+(difference_type _Off) const; + iterator& operator-=(difference_type _Off); + iterator operator-(difference_type _Off) const; + difference_type operator-(const const_iterator& _Right) const; + reference operator[](difference_type _Off) const; + friend iterator operator+(difference_type _Off, + const iterator& _Right); + }; + + typedef std::reverse_iterator<iterator> reverse_iterator; + typedef std::reverse_iterator<const_iterator> const_reverse_iterator; + +#elif (G__GNUC>=3 && G__GNUC_MINOR>=1) || defined(G__VISUAL) + +#ifndef G__OLDIMPLEMENTATION1703 + class iterator { + public: + iterator(); + explicit iterator(const pointer& __i) ; + // Allow iterator to const_iterator conversion + template<typename _Iter> inline iterator(const iterator& __i); + + // Forward iterator requirements + reference operator*() const ; + pointer operator->() const ; + iterator& operator++(); + iterator operator++(int) ; + + // Bidirectional iterator requirements + iterator& operator--() ; + iterator operator--(int) ; + + // Random access iterator requirements + reference operator[](const difference_type& __n) const; + iterator& operator+=(const difference_type& __n); + iterator operator+(const difference_type& __n) const; + iterator& operator-=(const difference_type& __n); + iterator operator-(const difference_type& __n) const; + const pointer& base() const ; + }; + friend bool operator==(const vector::iterator& x,const vector::iterator& y)const; + friend bool operator!=(const vector::iterator& x,const vector::iterator& y)const; + friend bool operator<(const vector::iterator& x,const vector::iterator& y)const; + friend bool operator>(const vector::iterator& x,const vector::iterator& y)const; + friend bool operator<=(const vector::iterator& x,const vector::iterator& y)const; + friend bool operator>=(const vector::iterator& x,const vector::iterator& y)const; + friend vector::iterator::difference_type operator-(const vector::iterator& x,const vector::iterator& y)const; + friend vector::iterator operator+(const vector::iterator::difference_type x,const vector::iterator& y)const; + typedef const iterator const_iterator; +#else /* 1703 */ + typedef vector<T, Allocator> vector_type; + typedef __gnu_cxx::__normal_iterator<pointer, vector_type> iterator; + typedef __gnu_cxx::__normal_iterator<const_pointer, vector_type> + const_iterator; +#endif /* 1703 */ + +#elif (G__GNUC>=3 && G__GNUC_MINOR==0) + typedef vector<T, Allocator> vector_type; + typedef std::__normal_iterator<T*, vector_type> iterator; + typedef std::__normal_iterator<T*, vector_type> const_iterator; + +#else + typedef T* iterator; + typedef const T* const_iterator; +#endif + + +#if defined(G__VISUAL) && (G__MSC_VER>=1300) + // already done above +#elif defined(G__BORLANDCC5) + typedef reverse_iterator<iterator> reverse_iterator; +#elif (G__GNUC>=3 && G__GNUC_MINOR>=1) || defined(G__AIX) + typedef reverse_iterator<const_iterator> const_reverse_iterator; + typedef reverse_iterator<iterator> reverse_iterator; +#else // G__BORLANDCC5 +#if defined(G__KCC) && 0 + //There is a bug in the CINT parsing of #if between the 'class X' and the body of the class + //declaration. so for now we keep this dummy test ... + // typedef reverse_iterator<iterator> reverse_iterator; +#else + class reverse_iterator +#if defined(G__VISUAL) + : public _Ranit<T,difference_type> +#elif !defined(G__SUNPRO_C) && !defined(G__INTEL_COMPILER) && !defined(G__KCC) && !defined(G__AIX) && !defined(G__ALPHA) + : public std::random_access_iterator<T,difference_type> +#endif + { + public: + reverse_iterator(const reverse_iterator& x) ; +#if !defined(G__BORLAND) && !defined(G__KCC) && !(defined (G__SGI)&&!defined(G__GNU)) && !defined(G__ALPHA) + reverse_iterator& operator=(const reverse_iterator& x) ; +#endif +#if !(G__GNUC>=3) && !defined(G__KCC) + T* base() ; +#else + iterator base() ; +#endif + T& operator*() const ; + reverse_iterator& operator++(); + reverse_iterator operator++(int a); + reverse_iterator& operator--(); + reverse_iterator operator--(int a); + reverse_iterator operator+(long n); + reverse_iterator operator-(long n); + reverse_iterator& operator+=(long n); + reverse_iterator& operator-=(long n); + T& operator[](long n) ; + private: + }; +#endif +#endif // G__BORLANDCC5 + friend bool operator==(const vector::reverse_iterator& x + ,const vector::reverse_iterator& y) const; + friend bool operator!=(const vector::reverse_iterator& x + ,const vector::reverse_iterator& y) const; + +#if !(G__GNUC>=3 && G__GNUC_MINOR>=1) + typedef const reverse_iterator const_reverse_iterator; +#endif + +#if (G__GNUC>=3) && !defined(G__KCC) + friend bool operator==(vector::const_iterator& x + ,vector::const_iterator& y) const; + friend bool operator!=(vector::const_iterator& x + ,vector::const_iterator& y) const; +#endif + +#if 0 + friend random_access_iterator_tag + iterator_category(random_access_iterator<T,vector::difference_type>& x); + //friend random_access_iterator_tag + //iterator_category(vector::reverse_iterator& x); +#endif + + iterator begin(void) ; + iterator end(void) ; + reverse_iterator rbegin(void) ; + reverse_iterator rend(void) ; +#ifdef G__CONSTNESSFLAG + const_iterator begin(void) const; + const_iterator end(void) const; + const_reverse_iterator rbegin(void) const; + const_reverse_iterator rend(void) const; +#endif + size_type size(void) const ; + size_type max_size(void) const ; + size_type capacity(void) const ; + bool empty(void) const ; + T& operator[](size_type n) ; + vector(void) ; + vector(size_type n,const T& value=T()) ; + vector(const vector& x) ; + vector(const_iterator first,const_iterator last) ; + ~vector(void) ; + vector& operator=(const vector& x); + void reserve(size_type n) ; + T& front(void) ; + T& back(void) ; + void push_back(const T& x) ; + void swap(vector& x); + iterator insert(iterator position,const T& x); + void insert(iterator position,const_iterator first,const_iterator last); + void insert(iterator position,size_type n,const T& x); + void pop_back(void) ; + void erase(iterator position) ; + void erase(iterator first,iterator last) ; + void clear() ; + +#if (G__GNUC>=3) || defined(G__KCC) + // doesn't work on VC++ 5.0 + friend bool operator==(const vector& x, const vector& y); + friend bool operator< (const vector& x, const vector& y); + friend bool operator!=(const vector& x, const vector& y); + friend bool operator> (const vector& x, const vector& y); + friend bool operator>=(const vector& x, const vector& y); + friend bool operator<=(const vector& x, const vector& y); +#endif + // specialized algorithms: +#if !defined(G__GNUC) || defined(G__KCC) + // doesn't work on egcs + friend void swap(vector& x, vector& y); +#endif + + +#ifndef G__NOALGORITHM + + // Generic algorithm +#if defined(G__GNUC) || defined(G__BORLAND) || defined(G__KCC) + + // input iter + friend vector::iterator + find(vector::iterator first,vector::iterator last,const T& value); + // forward iter + friend vector::iterator + find_end(vector::iterator first1,vector::iterator last1, + vector::iterator first2,vector::iterator last2); + friend vector::iterator + find_first_of(vector::iterator first1,vector::iterator last1, + vector::iterator first2,vector::iterator last2); + friend vector::iterator + adjacent_find(vector::iterator first,vector::iterator last); + // input iter +#if !defined(G__BORLAND) + friend vector::difference_type + count(vector::iterator first,vector::iterator last,const T& value); +#endif +#if 0 + friend pair<vector::iterator,vector::iterator> + mismatch(vector::iterator first1,vector::iterator last1, + vector::iterator first2); +#endif + friend bool + equal(vector::iterator first1,vector::iterator last1, + vector::iterator first2); + // forward iter + friend vector::iterator + search(vector::iterator first1,vector::iterator last1, + vector::iterator first2,vector::iterator last2); + friend vector::iterator + search_n(vector::iterator first,vector::iterator last + ,vector::size_type count,const T& value); + // input and output iter -> forward iter + friend vector::iterator + copy(vector::iterator first,vector::iterator last, + vector::iterator result); + // bidirectional iter + friend vector::iterator + copy_backward(vector::iterator first,vector::iterator last, + vector::iterator result); + // just value_type + friend void swap(T& a,T& b); + // forward iter + friend vector::iterator + swap_ranges(vector::iterator first1,vector::iterator last1, + vector::iterator first2); + friend void iter_swap(vector::iterator a,vector::iterator b); + friend void replace(vector::iterator first,vector::iterator last, + const T& old_value,const T& new_value); + // input, output iter -> forward iter + friend vector::iterator + replace_copy(vector::iterator first,vector::iterator last, + vector::iterator result, + const T& old_value,const T& new_value); + // forward iter + friend void + fill(vector::iterator first,vector::iterator last,const T& value); +#if (G__GNUC>=3) || defined(G__KCC) + friend void + fill_n(vector::iterator first,vector::size_type n,const T& value); +#endif + friend vector::iterator + remove(vector::iterator first,vector::iterator last,const T& value); + // input,output iter -> forward iter + friend vector::iterator + remove_copy(vector::iterator first,vector::iterator last, + vector::iterator result,const T& value); + friend vector::iterator + unique(vector::iterator first,vector::iterator last); + friend vector::iterator + unique_copy(vector::iterator first,vector::iterator last, + vector::iterator result); + friend void reverse(vector::iterator first,vector::iterator last); + friend vector::iterator + reverse_copy(vector::iterator first,vector::iterator last, + vector::iterator result); + // forward iter +#if (G__GNUC>=3) || defined(G__KCC) + friend void rotate(vector::iterator first,vector::iterator mid, + vector::iterator last); +#endif + // forward iter + friend vector::iterator + rotate_copy(vector::iterator first,vector::iterator mid, + vector::iterator last,vector::iterator result); + // randomaccess iter + friend void random_shuffle(vector::iterator first,vector::iterator last); + // randomaccess iter + friend void sort(vector::iterator first,vector::iterator last); + friend void stable_sort(vector::iterator first,vector::iterator last); + friend void partial_sort(vector::iterator first,vector::iterator mid, + vector::iterator last); + friend vector::iterator + partial_sort_copy(vector::iterator first,vector::iterator last, + vector::iterator result_first, + vector::iterator result_last); + friend void nth_element(vector::iterator first,vector::iterator nth, + vector::iterator last); + // forward iter + friend vector::iterator + lower_bound(vector::iterator first,vector::iterator last,const T& value); + friend vector::iterator + upper_bound(vector::iterator first,vector::iterator last,const T& value); +#if 0 + friend pair<vector::iterator,vector::iterator> + equal_range(vector::iterator first,vector::iterator last,const T& value); +#endif + friend bool binary_search(vector::iterator first,vector::iterator last, + const T& value); + friend vector::iterator merge(vector::iterator first1,vector::iterator last1, + vector::iterator first2,vector::iterator last2, + vector::iterator result); + friend void inplace_merge(vector::iterator first,vector::iterator middle, + vector::iterator last); + friend bool includes(vector::iterator first1,vector::iterator last1, + vector::iterator first2,vector::iterator last2); + friend vector::iterator + set_union(vector::iterator first1,vector::iterator last1, + vector::iterator first2,vector::iterator last2, + vector::iterator result); + friend vector::iterator + set_intersection(vector::iterator first1,vector::iterator last1, + vector::iterator first2,vector::iterator last2, + vector::iterator result); + friend vector::iterator + set_difference(vector::iterator first1,vector::iterator last1, + vector::iterator first2,vector::iterator last2, + vector::iterator result); + friend vector::iterator + set_symmetric_difference(vector::iterator first1,vector::iterator last1, + vector::iterator first2,vector::iterator last2, + vector::iterator result); + // random access + friend void push_heap(vector::iterator first,vector::iterator last); + friend void pop_heap(vector::iterator first,vector::iterator last); + friend void make_heap(vector::iterator first,vector::iterator last); + friend void sort_heap(vector::iterator first,vector::iterator last); + // min,max, just value_type + friend const T& min(const T& a,const T& b); + friend const T& max(const T& a,const T& b); + // forward iter + friend vector::iterator + min_element(vector::iterator first,vector::iterator last); + friend vector::iterator + max_element(vector::iterator first,vector::iterator last); + // input iter + friend bool + lexicographical_compare(vector::iterator first1,vector::iterator last1, + vector::iterator first2,vector::iterator last2); + // bidirectional iter + friend bool next_permutation(vector::iterator first,vector::iterator last); + friend bool prev_permutation(vector::iterator first,vector::iterator last); + +#elif defined(G__VISUAL) + + friend void reverse(vector::iterator first,vector::iterator last); + friend void sort(vector::iterator first,vector::iterator last); + + friend vector::iterator + find(vector::iterator first,vector::iterator last,const T& value); + friend vector::iterator + search(vector::iterator first1,vector::iterator last1, + vector::iterator first2,vector::iterator last2); + friend vector::iterator + copy(vector::iterator first,vector::iterator last, + vector::iterator result); + friend void + fill(vector::iterator first,vector::iterator last,const T& value); +#if 0 + // this is the limit that VC++ can handle + friend vector::iterator + remove(vector::iterator first,vector::iterator last,const T& value); + friend vector::iterator + unique(vector::iterator first,vector::iterator last); +#endif + +#endif // G__VISUAL,G__GNUC,G__BORLAND + +#endif // G__NOALGORITHM + + // iterator_category resolution + //friend random_access_iterator_tag iterator_category(vector::iterator x); + +}; + +#if 0 // G__defined("std::vector<bool>") +#pragma link off class std::vector<bool>::iterator; +#pragma link off function operator==(std::vector<bool>::iterator&,std::vector<bool>::iterator&); +#pragma link off function operator!=(std::vector<bool>::iterator&,std::vector<bool>::iterator&); +#pragma link off function operator<(std::vector<bool>::iterator&,std::vector<bool>::iterator&); +#pragma link off function operator>(std::vector<bool>::iterator&,std::vector<bool>::iterator&); +#pragma link off function operator<=(std::vector<bool>::iterator&,std::vector<bool>::iterator&); +#pragma link off function operator>=(std::vector<bool>::iterator&,std::vector<bool>::iterator&); +#endif + + + +#pragma endif -- GitLab