File indexing completed on 2025-01-18 09:34:41
0001
0002
0003
0004
0005
0006
0007 #if !defined(BOOST_FUSION_SEGMENTED_ITERATOR_NEXT_IMPL_HPP_INCLUDED)
0008 #define BOOST_FUSION_SEGMENTED_ITERATOR_NEXT_IMPL_HPP_INCLUDED
0009
0010 #include <boost/fusion/support/config.hpp>
0011 #include <boost/type_traits/add_const.hpp>
0012 #include <boost/type_traits/remove_reference.hpp>
0013 #include <boost/fusion/iterator/equal_to.hpp>
0014 #include <boost/fusion/container/list/cons_fwd.hpp>
0015 #include <boost/fusion/iterator/next.hpp>
0016 #include <boost/fusion/iterator/deref.hpp>
0017
0018 namespace boost { namespace fusion
0019 {
0020 template <typename First, typename Second>
0021 struct iterator_range;
0022
0023 template <typename Context>
0024 struct segmented_iterator;
0025
0026 namespace detail
0027 {
0028 template <typename Sequence, typename Stack>
0029 struct segmented_begin_impl;
0030
0031
0032
0033
0034
0035
0036 template <typename Stack>
0037 struct is_invalid
0038 : result_of::equal_to<
0039 typename Stack::car_type::begin_type,
0040 typename Stack::car_type::end_type
0041 >
0042 {};
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052 template <typename Stack>
0053 struct pop_front_car
0054 {
0055 typedef
0056 iterator_range<
0057 typename result_of::next<
0058 typename Stack::car_type::begin_type
0059 >::type
0060 , typename Stack::car_type::end_type
0061 >
0062 car_type;
0063
0064 typedef
0065 cons<car_type, typename Stack::cdr_type>
0066 type;
0067
0068 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0069 static type call(Stack const & stack)
0070 {
0071 return type(
0072 car_type(fusion::next(stack.car.first), stack.car.last),
0073 stack.cdr);
0074 }
0075 };
0076
0077 template <
0078 typename Stack,
0079 typename Next = typename pop_front_car<Stack>::type,
0080 bool IsInvalid = is_invalid<Next>::value,
0081 int StackSize = Stack::size::value>
0082 struct segmented_next_impl_recurse;
0083
0084
0085
0086
0087
0088
0089
0090
0091
0092
0093 template <
0094 typename Stack,
0095 int StackSize = Stack::size::value>
0096 struct segmented_next_impl_recurse3
0097 {
0098 typedef segmented_next_impl_recurse<typename Stack::cdr_type> impl;
0099 typedef typename impl::type type;
0100
0101 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0102 static type call(Stack const & stack)
0103 {
0104 return impl::call(stack.cdr);
0105 }
0106 };
0107
0108 template <typename Stack>
0109 struct segmented_next_impl_recurse3<Stack, 1>
0110 {
0111 typedef typename Stack::car_type::end_type end_type;
0112 typedef iterator_range<end_type, end_type> range_type;
0113 typedef cons<range_type> type;
0114
0115 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0116 static type call(Stack const & stack)
0117 {
0118 return type(range_type(stack.car.last, stack.car.last));
0119 }
0120 };
0121
0122
0123
0124
0125
0126
0127
0128
0129
0130
0131 template <
0132 typename Stack,
0133 typename Sequence =
0134 typename remove_reference<
0135 typename add_const<
0136 typename result_of::deref<
0137 typename Stack::car_type::begin_type
0138 >::type
0139 >::type
0140 >::type,
0141 typename Result =
0142 typename segmented_begin_impl<Sequence, Stack>::type,
0143 bool IsInvalid =
0144 is_invalid<Result>::value>
0145 struct segmented_next_impl_recurse2
0146 {
0147 typedef segmented_next_impl_recurse3<Stack> impl;
0148 typedef typename impl::type type;
0149
0150 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0151 static type call(Stack const & stack)
0152 {
0153 return impl::call(stack);
0154 }
0155 };
0156
0157 template <typename Stack, typename Sequence, typename Result>
0158 struct segmented_next_impl_recurse2<Stack, Sequence, Result, false>
0159 {
0160 typedef Result type;
0161
0162 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0163 static type call(Stack const & stack)
0164 {
0165 return segmented_begin_impl<Sequence, Stack>::call(*stack.car.first, stack);
0166 }
0167 };
0168
0169
0170
0171
0172
0173
0174
0175
0176
0177
0178
0179
0180
0181 template <typename Stack, typename Next, bool IsInvalid, int StackSize>
0182 struct segmented_next_impl_recurse
0183 {
0184 typedef
0185 typename segmented_next_impl_recurse<typename Stack::cdr_type>::type
0186 type;
0187
0188 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0189 static type call(Stack const& stack)
0190 {
0191 return segmented_next_impl_recurse<typename Stack::cdr_type>::call(stack.cdr);
0192 }
0193 };
0194
0195 template <typename Stack, typename Next>
0196 struct segmented_next_impl_recurse<Stack, Next, true, 1>
0197 {
0198 typedef Next type;
0199
0200 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0201 static type call(Stack const & stack)
0202 {
0203 return pop_front_car<Stack>::call(stack);
0204 }
0205 };
0206
0207 template <typename Stack, typename Next, int StackSize>
0208 struct segmented_next_impl_recurse<Stack, Next, false, StackSize>
0209 {
0210 typedef segmented_next_impl_recurse2<Next> impl;
0211 typedef typename impl::type type;
0212
0213 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0214 static type call(Stack const & stack)
0215 {
0216 return impl::call(pop_front_car<Stack>::call(stack));
0217 }
0218 };
0219
0220
0221
0222
0223
0224
0225
0226
0227
0228
0229
0230 template <
0231 typename Stack,
0232 typename Next = typename pop_front_car<Stack>::type,
0233 bool IsInvalid = is_invalid<Next>::value>
0234 struct segmented_next_impl_aux
0235 {
0236 typedef segmented_next_impl_recurse<typename Stack::cdr_type> impl;
0237 typedef typename impl::type type;
0238
0239 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0240 static type call(Stack const & stack)
0241 {
0242 return impl::call(stack.cdr);
0243 }
0244 };
0245
0246 template <typename Stack, typename Next>
0247 struct segmented_next_impl_aux<Stack, Next, false>
0248 {
0249 typedef Next type;
0250
0251 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0252 static type call(Stack const & stack)
0253 {
0254 return pop_front_car<Stack>::call(stack);
0255 }
0256 };
0257
0258 template <typename Stack>
0259 struct segmented_next_impl
0260 : segmented_next_impl_aux<Stack>
0261 {};
0262 }
0263 }}
0264
0265 #endif