Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:34:42

0001 /*=============================================================================
0002     Copyright (c) 2011 Eric Niebler
0003 
0004     Distributed under the Boost Software License, Version 1.0. (See accompanying
0005     file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0006 ==============================================================================*/
0007 #if !defined(BOOST_FUSION_SEGMENTED_BEGIN_IMPL_HPP_INCLUDED)
0008 #define BOOST_FUSION_SEGMENTED_BEGIN_IMPL_HPP_INCLUDED
0009 
0010 #include <boost/fusion/support/config.hpp>
0011 #include <boost/type_traits/remove_const.hpp>
0012 #include <boost/fusion/container/list/cons_fwd.hpp>
0013 #include <boost/fusion/sequence/intrinsic_fwd.hpp>
0014 #include <boost/fusion/support/is_segmented.hpp>
0015 #include <boost/fusion/sequence/intrinsic/detail/segmented_end_impl.hpp>
0016 #include <boost/fusion/support/detail/segmented_fold_until_impl.hpp>
0017 
0018 namespace boost { namespace fusion
0019 {
0020     template <typename First, typename Last>
0021     struct iterator_range;
0022 }}
0023 
0024 namespace boost { namespace fusion { namespace detail
0025 {
0026     struct segmented_begin_fun
0027     {
0028         template <typename Sequence, typename State, typename Context>
0029         struct apply
0030         {
0031             typedef
0032                 iterator_range<
0033                     typename fusion::result_of::begin<Sequence>::type
0034                   , typename fusion::result_of::end<Sequence>::type
0035                 >
0036             range_type;
0037 
0038             typedef cons<range_type, Context> type;
0039             typedef mpl::false_ continue_type;
0040 
0041             BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0042             static type call(Sequence& seq, State const&, Context const& context, segmented_begin_fun)
0043             {
0044                 return type(range_type(fusion::begin(seq), fusion::end(seq)), context);
0045             }
0046         };
0047     };
0048 
0049     template <typename Sequence, typename Stack, bool IsSegmented = traits::is_segmented<Sequence>::type::value>
0050     struct segmented_begin_impl_aux
0051     {
0052         typedef
0053             segmented_end_impl<Sequence, Stack>
0054         end_impl;
0055 
0056         typedef
0057             segmented_fold_until_impl<
0058                 Sequence
0059               , typename end_impl::type
0060               , Stack
0061               , segmented_begin_fun
0062             >
0063         fold_impl;
0064 
0065         typedef typename fold_impl::type type;
0066 
0067         BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0068         static type call(Sequence& seq, Stack const& stack)
0069         {
0070             return fold_impl::call(seq, end_impl::call(seq, stack), stack, segmented_begin_fun());
0071         }
0072     };
0073 
0074     template <typename Sequence, typename Stack>
0075     struct segmented_begin_impl_aux<Sequence, Stack, false>
0076     {
0077         typedef typename result_of::begin<Sequence>::type  begin_type;
0078         typedef typename result_of::end<Sequence>::type    end_type;
0079         typedef iterator_range<begin_type, end_type>    pair_type;
0080         typedef cons<pair_type, Stack>                  type;
0081 
0082         BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0083         static type call(Sequence& seq, Stack stack)
0084         {
0085             return type(pair_type(fusion::begin(seq), fusion::end(seq)), stack);
0086         }
0087     };
0088 
0089     template <typename Sequence, typename Stack>
0090     struct segmented_begin_impl
0091       : segmented_begin_impl_aux<Sequence, Stack>
0092     {};
0093 
0094 }}}
0095 
0096 #endif