]> git.donarmstrong.com Git - rsem.git/blob - boost/fusion/adapted/mpl/mpl_iterator.hpp
Updated boost to v1.55.0
[rsem.git] / boost / fusion / adapted / mpl / mpl_iterator.hpp
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_MPL_ITERATOR_05052005_0731)
8 #define FUSION_MPL_ITERATOR_05052005_0731
9
10 #include <boost/fusion/support/detail/mpl_iterator_category.hpp>
11 #include <boost/fusion/iterator/iterator_facade.hpp>
12 #include <boost/type_traits/remove_const.hpp>
13 #include <boost/mpl/deref.hpp>
14 #include <boost/mpl/next.hpp>
15 #include <boost/mpl/prior.hpp>
16 #include <boost/mpl/advance.hpp>
17 #include <boost/mpl/distance.hpp>
18
19 namespace boost { namespace fusion
20 {
21     template <typename Iterator_>
22     struct mpl_iterator
23         : iterator_facade<
24             mpl_iterator<Iterator_>
25           , typename detail::mpl_iterator_category<typename Iterator_::category>::type
26         >
27     {
28         typedef typename remove_const<Iterator_>::type iterator_type;
29
30         template <typename Iterator>
31         struct value_of : mpl::deref<typename Iterator::iterator_type> {};
32
33         template <typename Iterator>
34         struct deref
35         {
36             typedef typename mpl::deref<
37                 typename Iterator::iterator_type>::type
38             type;
39
40             static type
41             call(Iterator)
42             {
43                 return type();
44             }
45         };
46
47         template <typename Iterator>
48         struct next
49         {
50             typedef mpl_iterator<
51                 typename mpl::next<typename Iterator::iterator_type>::type> 
52             type;
53
54             static type
55             call(Iterator)
56             {
57                 return type();
58             }
59         };
60
61         template <typename Iterator>
62         struct prior
63         {
64             typedef mpl_iterator<
65                 typename mpl::prior<typename Iterator::iterator_type>::type> 
66             type;
67
68             static type
69             call(Iterator)
70             {
71                 return type();
72             }
73         };
74
75         template <typename Iterator, typename N>
76         struct advance
77         {
78             typedef mpl_iterator<
79                 typename mpl::advance<typename Iterator::iterator_type, N>::type>
80             type;
81
82             static type
83             call(Iterator const& /*i*/)
84             {
85                 return type();
86             }
87         };
88
89         template <typename I1, typename I2>
90         struct distance : 
91             mpl::distance<
92                 typename I1::iterator_type
93               , typename I2::iterator_type>
94         {
95             typedef typename 
96                 mpl::distance<
97                     typename I1::iterator_type
98                   , typename I2::iterator_type
99                 >::type
100             type;
101             
102             static type
103             call(I1 const&, I2 const&)
104             {
105                 return type();
106             }
107         };
108     };
109 }}
110
111 #endif
112
113