123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265 |
- #if !defined(BOOST_FUSION_SEGMENTED_ITERATOR_NEXT_IMPL_HPP_INCLUDED)
- #define BOOST_FUSION_SEGMENTED_ITERATOR_NEXT_IMPL_HPP_INCLUDED
- #include <boost/fusion/support/config.hpp>
- #include <boost/type_traits/add_const.hpp>
- #include <boost/type_traits/remove_reference.hpp>
- #include <boost/fusion/iterator/equal_to.hpp>
- #include <boost/fusion/container/list/cons_fwd.hpp>
- #include <boost/fusion/iterator/next.hpp>
- #include <boost/fusion/iterator/deref.hpp>
- namespace boost { namespace fusion
- {
- template <typename First, typename Second>
- struct iterator_range;
- template <typename Context>
- struct segmented_iterator;
- namespace detail
- {
- template <typename Sequence, typename Stack>
- struct segmented_begin_impl;
-
-
-
-
- template <typename Stack>
- struct is_invalid
- : result_of::equal_to<
- typename Stack::car_type::begin_type,
- typename Stack::car_type::end_type
- >
- {};
-
-
-
-
-
-
-
- template <typename Stack>
- struct pop_front_car
- {
- typedef
- iterator_range<
- typename result_of::next<
- typename Stack::car_type::begin_type
- >::type
- , typename Stack::car_type::end_type
- >
- car_type;
-
- typedef
- cons<car_type, typename Stack::cdr_type>
- type;
- BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
- static type call(Stack const & stack)
- {
- return type(
- car_type(fusion::next(stack.car.first), stack.car.last),
- stack.cdr);
- }
- };
- template <
- typename Stack,
- typename Next = typename pop_front_car<Stack>::type,
- bool IsInvalid = is_invalid<Next>::value,
- int StackSize = Stack::size::value>
- struct segmented_next_impl_recurse;
-
-
-
-
-
-
-
-
- template <
- typename Stack,
- int StackSize = Stack::size::value>
- struct segmented_next_impl_recurse3
- {
- typedef segmented_next_impl_recurse<typename Stack::cdr_type> impl;
- typedef typename impl::type type;
- BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
- static type call(Stack const & stack)
- {
- return impl::call(stack.cdr);
- }
- };
- template <typename Stack>
- struct segmented_next_impl_recurse3<Stack, 1>
- {
- typedef typename Stack::car_type::end_type end_type;
- typedef iterator_range<end_type, end_type> range_type;
- typedef cons<range_type> type;
- BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
- static type call(Stack const & stack)
- {
- return type(range_type(stack.car.last, stack.car.last));
- }
- };
-
-
-
-
-
-
-
-
- template <
- typename Stack,
- typename Sequence =
- typename remove_reference<
- typename add_const<
- typename result_of::deref<
- typename Stack::car_type::begin_type
- >::type
- >::type
- >::type,
- typename Result =
- typename segmented_begin_impl<Sequence, Stack>::type,
- bool IsInvalid =
- is_invalid<Result>::value>
- struct segmented_next_impl_recurse2
- {
- typedef segmented_next_impl_recurse3<Stack> impl;
- typedef typename impl::type type;
- BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
- static type call(Stack const & stack)
- {
- return impl::call(stack);
- }
- };
- template <typename Stack, typename Sequence, typename Result>
- struct segmented_next_impl_recurse2<Stack, Sequence, Result, false>
- {
- typedef Result type;
- BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
- static type call(Stack const & stack)
- {
- return segmented_begin_impl<Sequence, Stack>::call(*stack.car.first, stack);
- }
- };
-
-
-
-
-
-
-
-
-
-
-
- template <typename Stack, typename Next, bool IsInvalid, int StackSize>
- struct segmented_next_impl_recurse
- {
- typedef
- typename segmented_next_impl_recurse<typename Stack::cdr_type>::type
- type;
- BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
- static type call(Stack const& stack)
- {
- return segmented_next_impl_recurse<typename Stack::cdr_type>::call(stack.cdr);
- }
- };
- template <typename Stack, typename Next>
- struct segmented_next_impl_recurse<Stack, Next, true, 1>
- {
- typedef Next type;
- BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
- static type call(Stack const & stack)
- {
- return pop_front_car<Stack>::call(stack);
- }
- };
- template <typename Stack, typename Next, int StackSize>
- struct segmented_next_impl_recurse<Stack, Next, false, StackSize>
- {
- typedef segmented_next_impl_recurse2<Next> impl;
- typedef typename impl::type type;
- BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
- static type call(Stack const & stack)
- {
- return impl::call(pop_front_car<Stack>::call(stack));
- }
- };
-
-
-
-
-
-
-
-
-
- template <
- typename Stack,
- typename Next = typename pop_front_car<Stack>::type,
- bool IsInvalid = is_invalid<Next>::value>
- struct segmented_next_impl_aux
- {
- typedef segmented_next_impl_recurse<typename Stack::cdr_type> impl;
- typedef typename impl::type type;
- BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
- static type call(Stack const & stack)
- {
- return impl::call(stack.cdr);
- }
- };
- template <typename Stack, typename Next>
- struct segmented_next_impl_aux<Stack, Next, false>
- {
- typedef Next type;
- BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
- static type call(Stack const & stack)
- {
- return pop_front_car<Stack>::call(stack);
- }
- };
- template <typename Stack>
- struct segmented_next_impl
- : segmented_next_impl_aux<Stack>
- {};
- }
- }}
- #endif
|