File indexing completed on 2025-01-18 09:38:55
0001
0002
0003
0004
0005
0006
0007
0008 #ifndef BOOST_PERMUTATION_ITERATOR_HPP
0009 #define BOOST_PERMUTATION_ITERATOR_HPP
0010
0011 #include <iterator>
0012
0013 #include <boost/iterator/iterator_adaptor.hpp>
0014
0015
0016 namespace boost {
0017 namespace iterators {
0018
0019 template< class ElementIterator
0020 , class IndexIterator>
0021 class permutation_iterator
0022 : public iterator_adaptor<
0023 permutation_iterator<ElementIterator, IndexIterator>
0024 , IndexIterator, typename std::iterator_traits<ElementIterator>::value_type
0025 , use_default, typename std::iterator_traits<ElementIterator>::reference>
0026 {
0027 typedef iterator_adaptor<
0028 permutation_iterator<ElementIterator, IndexIterator>
0029 , IndexIterator, typename std::iterator_traits<ElementIterator>::value_type
0030 , use_default, typename std::iterator_traits<ElementIterator>::reference> super_t;
0031
0032 friend class iterator_core_access;
0033
0034 public:
0035 permutation_iterator() : m_elt_iter() {}
0036
0037 explicit permutation_iterator(ElementIterator x, IndexIterator y)
0038 : super_t(y), m_elt_iter(x) {}
0039
0040 template<class OtherElementIterator, class OtherIndexIterator>
0041 permutation_iterator(
0042 permutation_iterator<OtherElementIterator, OtherIndexIterator> const& r
0043 , typename enable_if_convertible<OtherElementIterator, ElementIterator>::type* = 0
0044 , typename enable_if_convertible<OtherIndexIterator, IndexIterator>::type* = 0
0045 )
0046 : super_t(r.base()), m_elt_iter(r.m_elt_iter)
0047 {}
0048
0049 private:
0050 typename super_t::reference dereference() const
0051 { return *(m_elt_iter + *this->base()); }
0052
0053 #ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
0054 template <class,class> friend class permutation_iterator;
0055 #else
0056 public:
0057 #endif
0058 ElementIterator m_elt_iter;
0059 };
0060
0061
0062 template <class ElementIterator, class IndexIterator>
0063 inline permutation_iterator<ElementIterator, IndexIterator>
0064 make_permutation_iterator( ElementIterator e, IndexIterator i )
0065 {
0066 return permutation_iterator<ElementIterator, IndexIterator>( e, i );
0067 }
0068
0069 }
0070
0071 using iterators::permutation_iterator;
0072 using iterators::make_permutation_iterator;
0073
0074 }
0075
0076 #endif