STLdoc
STLdocumentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Macros | Functions
Iterators

Macros

#define _GLIBCXX_MAKE_MOVE_ITERATOR(_Iter)   (_Iter)
 
#define _GLIBCXX_MAKE_MOVE_IF_NOEXCEPT_ITERATOR(_Iter)   (_Iter)
 

Functions

namespace __gnu_cxx _GLIBCXX_VISIBILITY (default)
 

Detailed Description

Abstractions for uniform iterating through various underlying types.

Macro Definition Documentation

#define _GLIBCXX_MAKE_MOVE_IF_NOEXCEPT_ITERATOR (   _Iter)    (_Iter)
#define _GLIBCXX_MAKE_MOVE_ITERATOR (   _Iter)    (_Iter)

Function Documentation

namespace __gnu_cxx _GLIBCXX_VISIBILITY ( default  )
695 {
696 _GLIBCXX_BEGIN_NAMESPACE_VERSION
697 
698  // This iterator adapter is @a normal in the sense that it does not
699  // change the semantics of any of the operators of its iterator
700  // parameter. Its primary purpose is to convert an iterator that is
701  // not a class, e.g. a pointer, into an iterator that is a class.
702  // The _Container parameter exists solely so that different containers
703  // using this template can instantiate different types, even if the
704  // _Iterator parameter is the same.
705  using std::iterator_traits;
706  using std::iterator;
707  template<typename _Iterator, typename _Container>
708  class __normal_iterator
709  {
710  protected:
711  _Iterator _M_current;
712 
713  typedef iterator_traits<_Iterator> __traits_type;
714 
715  public:
716  typedef _Iterator iterator_type;
717  typedef typename __traits_type::iterator_category iterator_category;
718  typedef typename __traits_type::value_type value_type;
719  typedef typename __traits_type::difference_type difference_type;
720  typedef typename __traits_type::reference reference;
721  typedef typename __traits_type::pointer pointer;
722 
723  _GLIBCXX_CONSTEXPR __normal_iterator() : _M_current(_Iterator()) { }
724 
725  explicit
726  __normal_iterator(const _Iterator& __i) : _M_current(__i) { }
727 
728  // Allow iterator to const_iterator conversion
729  template<typename _Iter>
730  __normal_iterator(const __normal_iterator<_Iter,
731  typename __enable_if<
732  (std::__are_same<_Iter, typename _Container::pointer>::__value),
733  _Container>::__type>& __i)
734  : _M_current(__i.base()) { }
735 
736  // Forward iterator requirements
737  reference
738  operator*() const
739  { return *_M_current; }
740 
741  pointer
742  operator->() const
743  { return _M_current; }
744 
745  __normal_iterator&
746  operator++()
747  {
748  ++_M_current;
749  return *this;
750  }
751 
752  __normal_iterator
753  operator++(int)
754  { return __normal_iterator(_M_current++); }
755 
756  // Bidirectional iterator requirements
757  __normal_iterator&
758  operator--()
759  {
760  --_M_current;
761  return *this;
762  }
763 
764  __normal_iterator
765  operator--(int)
766  { return __normal_iterator(_M_current--); }
767 
768  // Random access iterator requirements
769  reference
770  operator[](const difference_type& __n) const
771  { return _M_current[__n]; }
772 
773  __normal_iterator&
774  operator+=(const difference_type& __n)
775  { _M_current += __n; return *this; }
776 
777  __normal_iterator
778  operator+(const difference_type& __n) const
779  { return __normal_iterator(_M_current + __n); }
780 
781  __normal_iterator&
782  operator-=(const difference_type& __n)
783  { _M_current -= __n; return *this; }
784 
785  __normal_iterator
786  operator-(const difference_type& __n) const
787  { return __normal_iterator(_M_current - __n); }
788 
789  const _Iterator&
790  base() const
791  { return _M_current; }
792  };
793 
794  // Note: In what follows, the left- and right-hand-side iterators are
795  // allowed to vary in types (conceptually in cv-qualification) so that
796  // comparison between cv-qualified and non-cv-qualified iterators be
797  // valid. However, the greedy and unfriendly operators in std::rel_ops
798  // will make overload resolution ambiguous (when in scope) if we don't
799  // provide overloads whose operands are of the same type. Can someone
800  // remind me what generic programming is about? -- Gaby
801 
802  // Forward iterator requirements
803  template<typename _IteratorL, typename _IteratorR, typename _Container>
804  inline bool
805  operator==(const __normal_iterator<_IteratorL, _Container>& __lhs,
806  const __normal_iterator<_IteratorR, _Container>& __rhs)
807  { return __lhs.base() == __rhs.base(); }
808 
809  template<typename _Iterator, typename _Container>
810  inline bool
811  operator==(const __normal_iterator<_Iterator, _Container>& __lhs,
812  const __normal_iterator<_Iterator, _Container>& __rhs)
813  { return __lhs.base() == __rhs.base(); }
814 
815  template<typename _IteratorL, typename _IteratorR, typename _Container>
816  inline bool
817  operator!=(const __normal_iterator<_IteratorL, _Container>& __lhs,
818  const __normal_iterator<_IteratorR, _Container>& __rhs)
819  { return __lhs.base() != __rhs.base(); }
820 
821  template<typename _Iterator, typename _Container>
822  inline bool
823  operator!=(const __normal_iterator<_Iterator, _Container>& __lhs,
824  const __normal_iterator<_Iterator, _Container>& __rhs)
825  { return __lhs.base() != __rhs.base(); }
826 
827  // Random access iterator requirements
828  template<typename _IteratorL, typename _IteratorR, typename _Container>
829  inline bool
830  operator<(const __normal_iterator<_IteratorL, _Container>& __lhs,
831  const __normal_iterator<_IteratorR, _Container>& __rhs)
832  { return __lhs.base() < __rhs.base(); }
833 
834  template<typename _Iterator, typename _Container>
835  inline bool
836  operator<(const __normal_iterator<_Iterator, _Container>& __lhs,
837  const __normal_iterator<_Iterator, _Container>& __rhs)
838  { return __lhs.base() < __rhs.base(); }
839 
840  template<typename _IteratorL, typename _IteratorR, typename _Container>
841  inline bool
842  operator>(const __normal_iterator<_IteratorL, _Container>& __lhs,
843  const __normal_iterator<_IteratorR, _Container>& __rhs)
844  { return __lhs.base() > __rhs.base(); }
845 
846  template<typename _Iterator, typename _Container>
847  inline bool
848  operator>(const __normal_iterator<_Iterator, _Container>& __lhs,
849  const __normal_iterator<_Iterator, _Container>& __rhs)
850  { return __lhs.base() > __rhs.base(); }
851 
852  template<typename _IteratorL, typename _IteratorR, typename _Container>
853  inline bool
854  operator<=(const __normal_iterator<_IteratorL, _Container>& __lhs,
855  const __normal_iterator<_IteratorR, _Container>& __rhs)
856  { return __lhs.base() <= __rhs.base(); }
857 
858  template<typename _Iterator, typename _Container>
859  inline bool
860  operator<=(const __normal_iterator<_Iterator, _Container>& __lhs,
861  const __normal_iterator<_Iterator, _Container>& __rhs)
862  { return __lhs.base() <= __rhs.base(); }
863 
864  template<typename _IteratorL, typename _IteratorR, typename _Container>
865  inline bool
866  operator>=(const __normal_iterator<_IteratorL, _Container>& __lhs,
867  const __normal_iterator<_IteratorR, _Container>& __rhs)
868  { return __lhs.base() >= __rhs.base(); }
869 
870  template<typename _Iterator, typename _Container>
871  inline bool
872  operator>=(const __normal_iterator<_Iterator, _Container>& __lhs,
873  const __normal_iterator<_Iterator, _Container>& __rhs)
874  { return __lhs.base() >= __rhs.base(); }
875 
876  // _GLIBCXX_RESOLVE_LIB_DEFECTS
877  // According to the resolution of DR179 not only the various comparison
878  // operators but also operator- must accept mixed iterator/const_iterator
879  // parameters.
880  template<typename _IteratorL, typename _IteratorR, typename _Container>
881 #if __cplusplus >= 201103L
882  // DR 685.
883  inline auto
884  operator-(const __normal_iterator<_IteratorL, _Container>& __lhs,
885  const __normal_iterator<_IteratorR, _Container>& __rhs)
886  -> decltype(__lhs.base() - __rhs.base())
887 #else
888  inline typename __normal_iterator<_IteratorL, _Container>::difference_type
889  operator-(const __normal_iterator<_IteratorL, _Container>& __lhs,
890  const __normal_iterator<_IteratorR, _Container>& __rhs)
891 #endif
892  { return __lhs.base() - __rhs.base(); }
893 
894  template<typename _Iterator, typename _Container>
895  inline typename __normal_iterator<_Iterator, _Container>::difference_type
896  operator-(const __normal_iterator<_Iterator, _Container>& __lhs,
897  const __normal_iterator<_Iterator, _Container>& __rhs)
898  { return __lhs.base() - __rhs.base(); }
899 
900  template<typename _Iterator, typename _Container>
901  inline __normal_iterator<_Iterator, _Container>
902  operator+(typename __normal_iterator<_Iterator, _Container>::difference_type
903  __n, const __normal_iterator<_Iterator, _Container>& __i)
904  { return __normal_iterator<_Iterator, _Container>(__i.base() + __n); }
905 
906 _GLIBCXX_END_NAMESPACE_VERSION
907 } // namespace
bool operator>=(const _Safe_iterator< _IteratorL, _Sequence > &__lhs, const _Safe_iterator< _IteratorR, _Sequence > &__rhs)
Definition: safe_iterator.h:644
bool operator==(const exception_ptr &, const exception_ptr &) _GLIBCXX_USE_NOEXCEPT __attribute__((__pure__))
_Safe_iterator< _Iterator, _Sequence > operator+(typename _Safe_iterator< _Iterator, _Sequence >::difference_type __n, const _Safe_iterator< _Iterator, _Sequence > &__i)
Definition: safe_iterator.h:712
bool operator>(const _Safe_iterator< _IteratorL, _Sequence > &__lhs, const _Safe_iterator< _IteratorR, _Sequence > &__rhs)
Definition: safe_iterator.h:612
_Safe_iterator< _IteratorL, _Sequence >::difference_type operator-(const _Safe_iterator< _IteratorL, _Sequence > &__lhs, const _Safe_iterator< _IteratorR, _Sequence > &__rhs)
Definition: safe_iterator.h:680
bool operator!=(const exception_ptr &, const exception_ptr &) _GLIBCXX_USE_NOEXCEPT __attribute__((__pure__))