]> git.donarmstrong.com Git - rsem.git/blob - boost/fusion/sequence/intrinsic/detail/segmented_begin_impl.hpp
Updated boost to v1.55.0
[rsem.git] / boost / fusion / sequence / intrinsic / detail / segmented_begin_impl.hpp
1 /*=============================================================================
2     Copyright (c) 2011 Eric Niebler
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(BOOST_FUSION_SEGMENTED_BEGIN_IMPL_HPP_INCLUDED)
8 #define BOOST_FUSION_SEGMENTED_BEGIN_IMPL_HPP_INCLUDED
9
10 #include <boost/type_traits/remove_const.hpp>
11 #include <boost/fusion/container/list/cons_fwd.hpp>
12 #include <boost/fusion/sequence/intrinsic_fwd.hpp>
13 #include <boost/fusion/support/is_segmented.hpp>
14 #include <boost/fusion/sequence/intrinsic/detail/segmented_end_impl.hpp>
15 #include <boost/fusion/support/detail/segmented_fold_until_impl.hpp>
16
17 namespace boost { namespace fusion
18 {
19     template <typename First, typename Last>
20     struct iterator_range;
21 }}
22
23 namespace boost { namespace fusion { namespace detail
24 {
25     struct segmented_begin_fun
26     {
27         template <typename Sequence, typename State, typename Context>
28         struct apply
29         {
30             typedef
31                 iterator_range<
32                     typename fusion::result_of::begin<Sequence>::type
33                   , typename fusion::result_of::end<Sequence>::type
34                 >
35             range_type;
36
37             typedef cons<range_type, Context> type;
38             typedef mpl::false_ continue_type;
39
40             static type call(Sequence& seq, State const&, Context const& context, segmented_begin_fun)
41             {
42                 return type(range_type(fusion::begin(seq), fusion::end(seq)), context);
43             }
44         };
45     };
46
47     template <typename Sequence, typename Stack, bool IsSegmented = traits::is_segmented<Sequence>::type::value>
48     struct segmented_begin_impl_aux
49     {
50         typedef
51             segmented_end_impl<Sequence, Stack>
52         end_impl;
53
54         typedef
55             segmented_fold_until_impl<
56                 Sequence
57               , typename end_impl::type
58               , Stack
59               , segmented_begin_fun
60             >
61         fold_impl;
62
63         typedef typename fold_impl::type type;
64
65         static type call(Sequence& seq, Stack const& stack)
66         {
67             return fold_impl::call(seq, end_impl::call(seq, stack), stack, segmented_begin_fun());
68         }
69     };
70
71     template <typename Sequence, typename Stack>
72     struct segmented_begin_impl_aux<Sequence, Stack, false>
73     {
74         typedef typename result_of::begin<Sequence>::type  begin_type;
75         typedef typename result_of::end<Sequence>::type    end_type;
76         typedef iterator_range<begin_type, end_type>    pair_type;
77         typedef cons<pair_type, Stack>                  type;
78
79         static type call(Sequence& seq, Stack stack)
80         {
81             return type(pair_type(fusion::begin(seq), fusion::end(seq)), stack);
82         }
83     };
84
85     template <typename Sequence, typename Stack>
86     struct segmented_begin_impl
87       : segmented_begin_impl_aux<Sequence, Stack>
88     {};
89
90 }}}
91
92 #endif