| 
									
										
										
										
											2012-10-17 18:09:08 +09:00
										 |  |  | // Copyright David Abrahams and Thomas Becker 2000-2006.
 | 
					
						
							|  |  |  | // Copyright Kohei Takahashi 2012-2014.
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | // Distributed under the Boost Software License, Version 1.0. (See
 | 
					
						
							|  |  |  | // accompanying file LICENSE_1_0.txt or copy at
 | 
					
						
							| 
									
										
										
										
											2006-09-12 22:34:33 +00:00
										 |  |  | // http://www.boost.org/LICENSE_1_0.txt)
 | 
					
						
							| 
									
										
										
										
											2003-09-09 03:22:50 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | #ifndef BOOST_ZIP_ITERATOR_TMB_07_13_2003_HPP_
 | 
					
						
							| 
									
										
										
										
											2005-04-24 11:48:23 +00:00
										 |  |  | # define BOOST_ZIP_ITERATOR_TMB_07_13_2003_HPP_
 | 
					
						
							| 
									
										
										
										
											2003-09-09 03:22:50 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | #include <stddef.h>
 | 
					
						
							|  |  |  | #include <boost/iterator/iterator_traits.hpp>
 | 
					
						
							|  |  |  | #include <boost/iterator/iterator_facade.hpp>
 | 
					
						
							|  |  |  | #include <boost/iterator/iterator_adaptor.hpp> // for enable_if_convertible
 | 
					
						
							|  |  |  | #include <boost/iterator/iterator_categories.hpp>
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-07-19 21:39:49 +04:00
										 |  |  | #include <boost/iterator/minimum_category.hpp>
 | 
					
						
							| 
									
										
										
										
											2003-11-22 01:18:37 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-18 20:40:12 +09:00
										 |  |  | #include <utility> // for std::pair
 | 
					
						
							| 
									
										
										
										
											2012-10-17 18:09:08 +09:00
										 |  |  | #include <boost/fusion/adapted/boost_tuple.hpp> // for backward compatibility
 | 
					
						
							| 
									
										
										
										
											2003-09-09 03:22:50 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-17 18:09:08 +09:00
										 |  |  | #include <boost/type_traits/remove_reference.hpp>
 | 
					
						
							|  |  |  | #include <boost/type_traits/remove_cv.hpp>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <boost/mpl/at.hpp>
 | 
					
						
							|  |  |  | #include <boost/mpl/fold.hpp>
 | 
					
						
							|  |  |  | #include <boost/mpl/transform.hpp>
 | 
					
						
							| 
									
										
										
										
											2003-09-09 03:22:50 +00:00
										 |  |  | #include <boost/mpl/placeholders.hpp>
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-17 18:09:08 +09:00
										 |  |  | #include <boost/fusion/algorithm/iteration/for_each.hpp>
 | 
					
						
							|  |  |  | #include <boost/fusion/algorithm/transformation/transform.hpp>
 | 
					
						
							|  |  |  | #include <boost/fusion/sequence/convert.hpp>
 | 
					
						
							|  |  |  | #include <boost/fusion/sequence/intrinsic/at_c.hpp>
 | 
					
						
							|  |  |  | #include <boost/fusion/sequence/comparison/equal_to.hpp>
 | 
					
						
							|  |  |  | #include <boost/fusion/support/tag_of_fwd.hpp>
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-09-09 03:22:50 +00:00
										 |  |  | namespace boost { | 
					
						
							| 
									
										
										
										
											2014-07-03 00:22:45 +04:00
										 |  |  | namespace iterators { | 
					
						
							| 
									
										
										
										
											2003-09-09 03:22:50 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |   // Zip iterator forward declaration for zip_iterator_base
 | 
					
						
							|  |  |  |   template<typename IteratorTuple> | 
					
						
							|  |  |  |   class zip_iterator; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   namespace detail | 
					
						
							|  |  |  |   { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // Functors to be used with tuple algorithms
 | 
					
						
							|  |  |  |     //
 | 
					
						
							|  |  |  |     template<typename DiffType> | 
					
						
							|  |  |  |     class advance_iterator | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |     public: | 
					
						
							|  |  |  |       advance_iterator(DiffType step) : m_step(step) {} | 
					
						
							| 
									
										
										
										
											2012-10-17 18:09:08 +09:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-09-09 03:22:50 +00:00
										 |  |  |       template<typename Iterator> | 
					
						
							|  |  |  |       void operator()(Iterator& it) const | 
					
						
							|  |  |  |       { it += m_step; } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     private: | 
					
						
							|  |  |  |       DiffType m_step; | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  |     //
 | 
					
						
							|  |  |  |     struct increment_iterator | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |       template<typename Iterator> | 
					
						
							| 
									
										
										
										
											2012-10-17 18:09:08 +09:00
										 |  |  |       void operator()(Iterator& it) const | 
					
						
							| 
									
										
										
										
											2003-09-09 03:22:50 +00:00
										 |  |  |       { ++it; } | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  |     //
 | 
					
						
							|  |  |  |     struct decrement_iterator | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |       template<typename Iterator> | 
					
						
							| 
									
										
										
										
											2012-10-17 18:09:08 +09:00
										 |  |  |       void operator()(Iterator& it) const | 
					
						
							| 
									
										
										
										
											2003-09-09 03:22:50 +00:00
										 |  |  |       { --it; } | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  |     //
 | 
					
						
							|  |  |  |     struct dereference_iterator | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2012-10-17 18:09:08 +09:00
										 |  |  |       template<typename> | 
					
						
							|  |  |  |       struct result; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       template<typename This, typename Iterator> | 
					
						
							|  |  |  |       struct result<This(Iterator)> | 
					
						
							|  |  |  |       { | 
					
						
							| 
									
										
										
										
											2003-09-09 03:22:50 +00:00
										 |  |  |         typedef typename | 
					
						
							| 
									
										
										
										
											2017-03-14 20:45:48 +01:00
										 |  |  |           remove_cv<typename remove_reference<Iterator>::type>::type | 
					
						
							| 
									
										
										
										
											2012-10-17 18:09:08 +09:00
										 |  |  |         iterator; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-06-14 15:58:52 +09:00
										 |  |  |         typedef typename iterator_reference<iterator>::type type; | 
					
						
							| 
									
										
										
										
											2003-09-09 03:22:50 +00:00
										 |  |  |       }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       template<typename Iterator> | 
					
						
							| 
									
										
										
										
											2012-10-17 18:09:08 +09:00
										 |  |  |         typename result<dereference_iterator(Iterator)>::type | 
					
						
							|  |  |  |         operator()(Iterator const& it) const | 
					
						
							| 
									
										
										
										
											2003-09-09 03:22:50 +00:00
										 |  |  |       { return *it; } | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // Metafunction to obtain the type of the tuple whose element types
 | 
					
						
							|  |  |  |     // are the reference types of an iterator tuple.
 | 
					
						
							|  |  |  |     //
 | 
					
						
							|  |  |  |     template<typename IteratorTuple> | 
					
						
							|  |  |  |     struct tuple_of_references | 
					
						
							| 
									
										
										
										
											2012-10-17 18:09:08 +09:00
										 |  |  |       : mpl::transform< | 
					
						
							|  |  |  |             IteratorTuple, | 
					
						
							| 
									
										
										
										
											2003-09-09 03:22:50 +00:00
										 |  |  |             iterator_reference<mpl::_1> | 
					
						
							|  |  |  |           > | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-18 20:40:12 +09:00
										 |  |  |     // Specialization for std::pair
 | 
					
						
							|  |  |  |     template<typename Iterator1, typename Iterator2> | 
					
						
							|  |  |  |     struct tuple_of_references<std::pair<Iterator1, Iterator2> > | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         typedef std::pair< | 
					
						
							|  |  |  |             typename iterator_reference<Iterator1>::type | 
					
						
							|  |  |  |           , typename iterator_reference<Iterator2>::type | 
					
						
							|  |  |  |         > type; | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-09-09 03:22:50 +00:00
										 |  |  |     // Metafunction to obtain the minimal traversal tag in a tuple
 | 
					
						
							|  |  |  |     // of iterators.
 | 
					
						
							|  |  |  |     //
 | 
					
						
							|  |  |  |     template<typename IteratorTuple> | 
					
						
							|  |  |  |     struct minimum_traversal_category_in_iterator_tuple | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2012-10-17 18:09:08 +09:00
										 |  |  |       typedef typename mpl::transform< | 
					
						
							| 
									
										
										
										
											2003-09-09 03:22:50 +00:00
										 |  |  |           IteratorTuple | 
					
						
							| 
									
										
										
										
											2011-03-29 21:17:11 +00:00
										 |  |  |         , pure_traversal_tag<iterator_traversal<> > | 
					
						
							| 
									
										
										
										
											2003-09-09 03:22:50 +00:00
										 |  |  |       >::type tuple_of_traversal_tags; | 
					
						
							| 
									
										
										
										
											2012-10-17 18:09:08 +09:00
										 |  |  | 
 | 
					
						
							|  |  |  |       typedef typename mpl::fold< | 
					
						
							| 
									
										
										
										
											2003-09-09 03:22:50 +00:00
										 |  |  |           tuple_of_traversal_tags | 
					
						
							|  |  |  |         , random_access_traversal_tag | 
					
						
							| 
									
										
										
										
											2012-10-17 18:09:08 +09:00
										 |  |  |         , minimum_category<> | 
					
						
							| 
									
										
										
										
											2003-09-09 03:22:50 +00:00
										 |  |  |       >::type type; | 
					
						
							|  |  |  |     }; | 
					
						
							| 
									
										
										
										
											2014-06-06 00:56:20 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-18 20:40:12 +09:00
										 |  |  |     template<typename Iterator1, typename Iterator2> | 
					
						
							|  |  |  |     struct minimum_traversal_category_in_iterator_tuple<std::pair<Iterator1, Iterator2> > | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         typedef typename pure_traversal_tag< | 
					
						
							|  |  |  |             typename iterator_traversal<Iterator1>::type | 
					
						
							|  |  |  |         >::type iterator1_traversal; | 
					
						
							|  |  |  |         typedef typename pure_traversal_tag< | 
					
						
							|  |  |  |             typename iterator_traversal<Iterator2>::type | 
					
						
							|  |  |  |         >::type iterator2_traversal; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         typedef typename minimum_category< | 
					
						
							|  |  |  |             iterator1_traversal | 
					
						
							|  |  |  |           , typename minimum_category< | 
					
						
							|  |  |  |                 iterator2_traversal | 
					
						
							|  |  |  |               , random_access_traversal_tag | 
					
						
							|  |  |  |             >::type | 
					
						
							|  |  |  |         >::type type; | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-09-09 03:22:50 +00:00
										 |  |  |     ///////////////////////////////////////////////////////////////////
 | 
					
						
							|  |  |  |     //
 | 
					
						
							|  |  |  |     // Class zip_iterator_base
 | 
					
						
							|  |  |  |     //
 | 
					
						
							| 
									
										
										
										
											2012-10-17 18:09:08 +09:00
										 |  |  |     // Builds and exposes the iterator facade type from which the zip
 | 
					
						
							| 
									
										
										
										
											2003-09-09 03:22:50 +00:00
										 |  |  |     // iterator will be derived.
 | 
					
						
							|  |  |  |     //
 | 
					
						
							|  |  |  |     template<typename IteratorTuple> | 
					
						
							|  |  |  |     struct zip_iterator_base | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |      private: | 
					
						
							|  |  |  |         // Reference type is the type of the tuple obtained from the
 | 
					
						
							|  |  |  |         // iterators' reference types.
 | 
					
						
							| 
									
										
										
										
											2012-10-17 18:09:08 +09:00
										 |  |  |         typedef typename | 
					
						
							| 
									
										
										
										
											2003-09-09 03:22:50 +00:00
										 |  |  |         detail::tuple_of_references<IteratorTuple>::type reference; | 
					
						
							| 
									
										
										
										
											2012-10-17 18:09:08 +09:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-09-09 03:22:50 +00:00
										 |  |  |         // Value type is the same as reference type.
 | 
					
						
							|  |  |  |         typedef reference value_type; | 
					
						
							| 
									
										
										
										
											2012-10-17 18:09:08 +09:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-09-09 03:22:50 +00:00
										 |  |  |         // Difference type is the first iterator's difference type
 | 
					
						
							| 
									
										
										
										
											2014-06-14 15:58:52 +09:00
										 |  |  |         typedef typename iterator_difference< | 
					
						
							| 
									
										
										
										
											2012-10-17 18:09:08 +09:00
										 |  |  |             typename mpl::at_c<IteratorTuple, 0>::type | 
					
						
							| 
									
										
										
										
											2014-06-14 15:58:52 +09:00
										 |  |  |         >::type difference_type; | 
					
						
							| 
									
										
										
										
											2012-10-17 18:09:08 +09:00
										 |  |  | 
 | 
					
						
							|  |  |  |         // Traversal catetgory is the minimum traversal category in the
 | 
					
						
							| 
									
										
										
										
											2003-09-09 03:22:50 +00:00
										 |  |  |         // iterator tuple.
 | 
					
						
							| 
									
										
										
										
											2012-10-17 18:09:08 +09:00
										 |  |  |         typedef typename | 
					
						
							| 
									
										
										
										
											2003-09-09 03:22:50 +00:00
										 |  |  |         detail::minimum_traversal_category_in_iterator_tuple< | 
					
						
							|  |  |  |             IteratorTuple | 
					
						
							|  |  |  |         >::type traversal_category; | 
					
						
							|  |  |  |      public: | 
					
						
							| 
									
										
										
										
											2012-10-17 18:09:08 +09:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-09-09 03:22:50 +00:00
										 |  |  |         // The iterator facade type from which the zip iterator will
 | 
					
						
							|  |  |  |         // be derived.
 | 
					
						
							|  |  |  |         typedef iterator_facade< | 
					
						
							|  |  |  |             zip_iterator<IteratorTuple>, | 
					
						
							| 
									
										
										
										
											2012-10-17 18:09:08 +09:00
										 |  |  |             value_type, | 
					
						
							| 
									
										
										
										
											2003-09-09 03:22:50 +00:00
										 |  |  |             traversal_category, | 
					
						
							|  |  |  |             reference, | 
					
						
							|  |  |  |             difference_type | 
					
						
							|  |  |  |         > type; | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     template <> | 
					
						
							|  |  |  |     struct zip_iterator_base<int> | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         typedef int type; | 
					
						
							|  |  |  |     }; | 
					
						
							| 
									
										
										
										
											2012-10-18 20:40:12 +09:00
										 |  |  | 
 | 
					
						
							|  |  |  |     template <typename reference> | 
					
						
							|  |  |  |     struct converter | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         template <typename Seq> | 
					
						
							|  |  |  |         static reference call(Seq seq) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             typedef typename fusion::traits::tag_of<reference>::type tag; | 
					
						
							|  |  |  |             return fusion::convert<tag>(seq); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     template <typename Reference1, typename Reference2> | 
					
						
							|  |  |  |     struct converter<std::pair<Reference1, Reference2> > | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         typedef std::pair<Reference1, Reference2> reference; | 
					
						
							|  |  |  |         template <typename Seq> | 
					
						
							|  |  |  |         static reference call(Seq seq) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             return reference( | 
					
						
							|  |  |  |                 fusion::at_c<0>(seq) | 
					
						
							|  |  |  |               , fusion::at_c<1>(seq)); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     }; | 
					
						
							| 
									
										
										
										
											2003-09-09 03:22:50 +00:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2012-10-17 18:09:08 +09:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-09-09 03:22:50 +00:00
										 |  |  |   /////////////////////////////////////////////////////////////////////
 | 
					
						
							|  |  |  |   //
 | 
					
						
							|  |  |  |   // zip_iterator class definition
 | 
					
						
							|  |  |  |   //
 | 
					
						
							|  |  |  |   template<typename IteratorTuple> | 
					
						
							| 
									
										
										
										
											2012-10-17 18:09:08 +09:00
										 |  |  |   class zip_iterator : | 
					
						
							| 
									
										
										
										
											2003-09-09 03:22:50 +00:00
										 |  |  |     public detail::zip_iterator_base<IteratorTuple>::type | 
					
						
							| 
									
										
										
										
											2012-10-17 18:09:08 +09:00
										 |  |  |   { | 
					
						
							| 
									
										
										
										
											2003-09-09 03:22:50 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-17 18:09:08 +09:00
										 |  |  |    // Typedef super_t as our base class.
 | 
					
						
							|  |  |  |    typedef typename | 
					
						
							| 
									
										
										
										
											2003-09-09 03:22:50 +00:00
										 |  |  |      detail::zip_iterator_base<IteratorTuple>::type super_t; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |    // iterator_core_access is the iterator's best friend.
 | 
					
						
							|  |  |  |    friend class iterator_core_access; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   public: | 
					
						
							| 
									
										
										
										
											2012-10-17 18:09:08 +09:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-09-09 03:22:50 +00:00
										 |  |  |     // Construction
 | 
					
						
							|  |  |  |     // ============
 | 
					
						
							| 
									
										
										
										
											2012-10-17 18:09:08 +09:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-09-09 03:22:50 +00:00
										 |  |  |     // Default constructor
 | 
					
						
							|  |  |  |     zip_iterator() { } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // Constructor from iterator tuple
 | 
					
						
							| 
									
										
										
										
											2012-10-17 18:09:08 +09:00
										 |  |  |     zip_iterator(IteratorTuple iterator_tuple) | 
					
						
							|  |  |  |       : m_iterator_tuple(iterator_tuple) | 
					
						
							| 
									
										
										
										
											2003-09-09 03:22:50 +00:00
										 |  |  |     { } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // Copy constructor
 | 
					
						
							|  |  |  |     template<typename OtherIteratorTuple> | 
					
						
							|  |  |  |     zip_iterator( | 
					
						
							|  |  |  |        const zip_iterator<OtherIteratorTuple>& other, | 
					
						
							|  |  |  |        typename enable_if_convertible< | 
					
						
							|  |  |  |          OtherIteratorTuple, | 
					
						
							|  |  |  |          IteratorTuple | 
					
						
							|  |  |  |          >::type* = 0 | 
					
						
							|  |  |  |     ) : m_iterator_tuple(other.get_iterator_tuple()) | 
					
						
							|  |  |  |     {} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // Get method for the iterator tuple.
 | 
					
						
							|  |  |  |     const IteratorTuple& get_iterator_tuple() const | 
					
						
							|  |  |  |     { return m_iterator_tuple; } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   private: | 
					
						
							| 
									
										
										
										
											2012-10-17 18:09:08 +09:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-09-09 03:22:50 +00:00
										 |  |  |     // Implementation of Iterator Operations
 | 
					
						
							|  |  |  |     // =====================================
 | 
					
						
							| 
									
										
										
										
											2012-10-17 18:09:08 +09:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-09-09 03:22:50 +00:00
										 |  |  |     // Dereferencing returns a tuple built from the dereferenced
 | 
					
						
							|  |  |  |     // iterators in the iterator tuple.
 | 
					
						
							|  |  |  |     typename super_t::reference dereference() const | 
					
						
							| 
									
										
										
										
											2012-10-17 18:09:08 +09:00
										 |  |  |     { | 
					
						
							|  |  |  |         typedef typename super_t::reference reference; | 
					
						
							| 
									
										
										
										
											2012-10-18 20:40:12 +09:00
										 |  |  |         typedef detail::converter<reference> gen; | 
					
						
							|  |  |  |         return gen::call(fusion::transform( | 
					
						
							| 
									
										
										
										
											2012-10-17 18:09:08 +09:00
										 |  |  |           get_iterator_tuple(), | 
					
						
							|  |  |  |           detail::dereference_iterator())); | 
					
						
							| 
									
										
										
										
											2003-09-09 03:22:50 +00:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // Two zip iterators are equal if all iterators in the iterator
 | 
					
						
							|  |  |  |     // tuple are equal. NOTE: It should be possible to implement this
 | 
					
						
							|  |  |  |     // as
 | 
					
						
							|  |  |  |     //
 | 
					
						
							|  |  |  |     // return get_iterator_tuple() == other.get_iterator_tuple();
 | 
					
						
							|  |  |  |     //
 | 
					
						
							|  |  |  |     // but equality of tuples currently (7/2003) does not compile
 | 
					
						
							|  |  |  |     // under several compilers. No point in bringing in a bunch
 | 
					
						
							|  |  |  |     // of #ifdefs here.
 | 
					
						
							|  |  |  |     //
 | 
					
						
							| 
									
										
										
										
											2012-10-17 18:09:08 +09:00
										 |  |  |     template<typename OtherIteratorTuple> | 
					
						
							| 
									
										
										
										
											2003-09-09 03:22:50 +00:00
										 |  |  |     bool equal(const zip_iterator<OtherIteratorTuple>& other) const | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2012-10-17 18:09:08 +09:00
										 |  |  |         return fusion::equal_to( | 
					
						
							|  |  |  |           get_iterator_tuple(), | 
					
						
							|  |  |  |           other.get_iterator_tuple()); | 
					
						
							| 
									
										
										
										
											2003-09-09 03:22:50 +00:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // Advancing a zip iterator means to advance all iterators in the
 | 
					
						
							|  |  |  |     // iterator tuple.
 | 
					
						
							|  |  |  |     void advance(typename super_t::difference_type n) | 
					
						
							| 
									
										
										
										
											2012-10-17 18:09:08 +09:00
										 |  |  |     { | 
					
						
							|  |  |  |         fusion::for_each( | 
					
						
							| 
									
										
										
										
											2003-09-09 03:22:50 +00:00
										 |  |  |           m_iterator_tuple, | 
					
						
							| 
									
										
										
										
											2012-10-17 18:09:08 +09:00
										 |  |  |           detail::advance_iterator<BOOST_DEDUCED_TYPENAME super_t::difference_type>(n)); | 
					
						
							| 
									
										
										
										
											2003-09-09 03:22:50 +00:00
										 |  |  |     } | 
					
						
							|  |  |  |     // Incrementing a zip iterator means to increment all iterators in
 | 
					
						
							|  |  |  |     // the iterator tuple.
 | 
					
						
							|  |  |  |     void increment() | 
					
						
							| 
									
										
										
										
											2012-10-17 18:09:08 +09:00
										 |  |  |     { | 
					
						
							|  |  |  |         fusion::for_each( | 
					
						
							|  |  |  |           m_iterator_tuple, | 
					
						
							|  |  |  |           detail::increment_iterator()); | 
					
						
							| 
									
										
										
										
											2003-09-09 03:22:50 +00:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2012-10-17 18:09:08 +09:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-09-09 03:22:50 +00:00
										 |  |  |     // Decrementing a zip iterator means to decrement all iterators in
 | 
					
						
							|  |  |  |     // the iterator tuple.
 | 
					
						
							|  |  |  |     void decrement() | 
					
						
							| 
									
										
										
										
											2012-10-17 18:09:08 +09:00
										 |  |  |     { | 
					
						
							|  |  |  |         fusion::for_each( | 
					
						
							|  |  |  |           m_iterator_tuple, | 
					
						
							|  |  |  |           detail::decrement_iterator()); | 
					
						
							| 
									
										
										
										
											2003-09-09 03:22:50 +00:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2012-10-17 18:09:08 +09:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-09-09 03:22:50 +00:00
										 |  |  |     // Distance is calculated using the first iterator in the tuple.
 | 
					
						
							|  |  |  |     template<typename OtherIteratorTuple> | 
					
						
							|  |  |  |       typename super_t::difference_type distance_to( | 
					
						
							|  |  |  |         const zip_iterator<OtherIteratorTuple>& other | 
					
						
							|  |  |  |         ) const | 
					
						
							| 
									
										
										
										
											2012-10-17 18:09:08 +09:00
										 |  |  |     { | 
					
						
							|  |  |  |         return fusion::at_c<0>(other.get_iterator_tuple()) - | 
					
						
							|  |  |  |             fusion::at_c<0>(this->get_iterator_tuple()); | 
					
						
							| 
									
										
										
										
											2003-09-09 03:22:50 +00:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2012-10-17 18:09:08 +09:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-09-09 03:22:50 +00:00
										 |  |  |     // Data Members
 | 
					
						
							|  |  |  |     // ============
 | 
					
						
							| 
									
										
										
										
											2012-10-17 18:09:08 +09:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-09-09 03:22:50 +00:00
										 |  |  |     // The iterator tuple.
 | 
					
						
							|  |  |  |     IteratorTuple m_iterator_tuple; | 
					
						
							| 
									
										
										
										
											2012-10-17 18:09:08 +09:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-09-09 03:22:50 +00:00
										 |  |  |   }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   // Make function for zip iterator
 | 
					
						
							|  |  |  |   //
 | 
					
						
							| 
									
										
										
										
											2012-10-17 18:09:08 +09:00
										 |  |  |   template<typename IteratorTuple> | 
					
						
							| 
									
										
										
										
											2014-06-14 15:54:37 +09:00
										 |  |  |   inline zip_iterator<IteratorTuple> | 
					
						
							| 
									
										
										
										
											2003-09-09 03:22:50 +00:00
										 |  |  |   make_zip_iterator(IteratorTuple t) | 
					
						
							|  |  |  |   { return zip_iterator<IteratorTuple>(t); } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-07-03 00:22:45 +04:00
										 |  |  | } // namespace iterators
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | using iterators::zip_iterator; | 
					
						
							|  |  |  | using iterators::make_zip_iterator; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } // namespace boost
 | 
					
						
							| 
									
										
										
										
											2003-09-09 03:22:50 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | #endif
 |