1 /*=============================================================================
2 Copyright (c) 2001-2006 Joel de Guzman
4 Distributed under the Boost Software License, Version 1.0. (See accompanying
5 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 ==============================================================================*/
7 #if !defined(FUSION_ADVANCE_09172005_1146)
8 #define FUSION_ADVANCE_09172005_1146
10 #include <boost/fusion/iterator/detail/advance.hpp>
11 #include <boost/fusion/support/category_of.hpp>
13 #include <boost/mpl/int.hpp>
14 #include <boost/mpl/assert.hpp>
15 #include <boost/type_traits/is_same.hpp>
16 #include <boost/fusion/support/tag_of.hpp>
18 namespace boost
{ namespace fusion
20 struct random_access_traversal_tag
;
23 struct iterator_facade_tag
; // iterator facade tag
24 struct array_iterator_tag
; // boost::array iterator tag
25 struct mpl_iterator_tag
; // mpl sequence iterator tag
26 struct std_pair_iterator_tag
; // std::pair iterator tag
30 template <typename Tag
>
33 // default implementation
34 template <typename Iterator
, typename N
>
38 , advance_detail::forward
<Iterator
, N::value
>
39 , advance_detail::backward
<Iterator
, N::value
>
42 BOOST_MPL_ASSERT_NOT((traits::is_random_access
<Iterator
>));
47 struct advance_impl
<iterator_facade_tag
>
49 template <typename Iterator
, typename N
>
50 struct apply
: Iterator::template advance
<Iterator
, N
> {};
54 struct advance_impl
<array_iterator_tag
>;
57 struct advance_impl
<mpl_iterator_tag
>;
60 struct advance_impl
<std_pair_iterator_tag
>;
65 template <typename Iterator
, int N
>
67 : extension::advance_impl
<typename
detail::tag_of
<Iterator
>::type
>::template apply
<Iterator
, mpl::int_
<N
> >
70 template <typename Iterator
, typename N
>
72 : extension::advance_impl
<typename
detail::tag_of
<Iterator
>::type
>::template apply
<Iterator
, N
>
76 template <int N
, typename Iterator
>
77 inline typename
result_of::advance_c
<Iterator
, N
>::type
const
78 advance_c(Iterator
const& i
)
80 return result_of::advance_c
<Iterator
, N
>::call(i
);
83 template<typename N
, typename Iterator
>
84 inline typename
result_of::advance
<Iterator
, N
>::type
const
85 advance(Iterator
const& i
)
87 return result_of::advance
<Iterator
, N
>::call(i
);
90 }} // namespace boost::fusion