Mercurial > hg > vamp-build-and-test
comparison DEPENDENCIES/generic/include/boost/fusion/iterator/advance.hpp @ 16:2665513ce2d3
Add boost headers
author | Chris Cannam |
---|---|
date | Tue, 05 Aug 2014 11:11:38 +0100 |
parents | |
children | c530137014c0 |
comparison
equal
deleted
inserted
replaced
15:663ca0da4350 | 16:2665513ce2d3 |
---|---|
1 /*============================================================================= | |
2 Copyright (c) 2001-2011 Joel de Guzman | |
3 | |
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 | |
9 | |
10 #include <boost/fusion/iterator/detail/advance.hpp> | |
11 #include <boost/fusion/support/category_of.hpp> | |
12 | |
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> | |
17 | |
18 namespace boost { namespace fusion | |
19 { | |
20 struct random_access_traversal_tag; | |
21 | |
22 // Special tags: | |
23 struct iterator_facade_tag; // iterator facade tag | |
24 struct boost_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 | |
27 | |
28 namespace extension | |
29 { | |
30 template <typename Tag> | |
31 struct advance_impl | |
32 { | |
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 | |
41 { | |
42 BOOST_MPL_ASSERT_NOT((traits::is_random_access<Iterator>)); | |
43 }; | |
44 }; | |
45 | |
46 template <> | |
47 struct advance_impl<iterator_facade_tag> | |
48 { | |
49 template <typename Iterator, typename N> | |
50 struct apply : Iterator::template advance<Iterator, N> {}; | |
51 }; | |
52 | |
53 template <> | |
54 struct advance_impl<boost_array_iterator_tag>; | |
55 | |
56 template <> | |
57 struct advance_impl<mpl_iterator_tag>; | |
58 | |
59 template <> | |
60 struct advance_impl<std_pair_iterator_tag>; | |
61 } | |
62 | |
63 namespace result_of | |
64 { | |
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 {}; | |
69 | |
70 template <typename Iterator, typename N> | |
71 struct advance | |
72 : extension::advance_impl<typename detail::tag_of<Iterator>::type>::template apply<Iterator, N> | |
73 {}; | |
74 } | |
75 | |
76 template <int N, typename Iterator> | |
77 inline typename result_of::advance_c<Iterator, N>::type const | |
78 advance_c(Iterator const& i) | |
79 { | |
80 return result_of::advance_c<Iterator, N>::call(i); | |
81 } | |
82 | |
83 template<typename N, typename Iterator> | |
84 inline typename result_of::advance<Iterator, N>::type const | |
85 advance(Iterator const& i) | |
86 { | |
87 return result_of::advance<Iterator, N>::call(i); | |
88 } | |
89 | |
90 }} // namespace boost::fusion | |
91 | |
92 #endif |