fix doc example typo
[boost.git] / boost / fusion / iterator / advance.hpp
blob2cbafedec36d7a9f0241582f5cba1f83aaa600cf
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;
22 // Special tags:
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
28 namespace extension
30 template <typename Tag>
31 struct advance_impl
33 // default implementation
34 template <typename Iterator, typename N>
35 struct apply :
36 mpl::if_c<
37 (N::value > 0)
38 , advance_detail::forward<Iterator, N::value>
39 , advance_detail::backward<Iterator, N::value>
40 >::type
42 BOOST_MPL_ASSERT_NOT((traits::is_random_access<Iterator>));
46 template <>
47 struct advance_impl<iterator_facade_tag>
49 template <typename Iterator, typename N>
50 struct apply : Iterator::template advance<Iterator, N> {};
53 template <>
54 struct advance_impl<array_iterator_tag>;
56 template <>
57 struct advance_impl<mpl_iterator_tag>;
59 template <>
60 struct advance_impl<std_pair_iterator_tag>;
63 namespace result_of
65 template <typename Iterator, int N>
66 struct advance_c
67 : extension::advance_impl<typename detail::tag_of<Iterator>::type>::template apply<Iterator, mpl::int_<N> >
68 {};
70 template <typename Iterator, typename N>
71 struct advance
72 : extension::advance_impl<typename detail::tag_of<Iterator>::type>::template apply<Iterator, N>
73 {};
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
92 #endif