13 #ifndef TRSL_REORDER_ITERATOR_HPP
14 #define TRSL_REORDER_ITERATOR_HPP
22 #include <boost/iterator.hpp>
23 #include <boost/detail/iterator.hpp>
24 #include <boost/iterator/iterator_categories.hpp>
25 #include <boost/iterator/iterator_adaptor.hpp>
26 #include <boost/shared_ptr.hpp>
30 template<
class ElementIterator>
36 template<
class ElementIterator>
39 typedef ElementIterator element_iterator;
40 typedef size_t index_t;
41 typedef std::vector<index_t> index_container;
42 typedef boost::shared_ptr<index_container> index_container_ptr;
43 typedef typename index_container::const_iterator index_iterator;
45 typedef boost::iterator_adaptor<
48 typename boost::detail::iterator_traits<ElementIterator>::value_type,
50 typename boost::detail::iterator_traits<ElementIterator>::reference
94 template<
class ElementIterator>
99 typedef typename base_t::type super_t;
101 friend class boost::iterator_core_access;
105 typedef typename base_t::index_t index_t;
106 typedef typename base_t::index_container index_container;
107 typedef typename base_t::index_container_ptr index_container_ptr;
108 typedef typename base_t::index_iterator index_iterator;
111 typedef typename base_t::element_iterator element_iterator;
115 m_index_collection(new index_container)
124 const index_container_ptr& index_collection)
125 : super_t(index_collection->
begin()),
127 m_index_collection(index_collection)
140 template<
class OtherElementIterator>
143 typename boost::enable_if_convertible<OtherElementIterator, ElementIterator>::type* = 0) :
144 super_t(r.base()), m_elt_iter(r.m_elt_iter),
145 m_index_collection(r.m_index_collection)
155 indexIterator.base_reference() =
156 indexIterator.m_index_collection->begin();
157 return indexIterator;
167 indexIterator.base_reference() =
168 indexIterator.m_index_collection->end();
169 return indexIterator;
178 return *this->base();
183 typename super_t::reference dereference()
const
184 {
return *(m_elt_iter + *this->base()); }
186 #ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
187 template <
class>
friend class reorder_iterator;
191 ElementIterator m_elt_iter;
193 index_container_ptr m_index_collection;
198 #endif // include guard