File indexing completed on 2025-01-18 09:31:09
0001
0002
0003
0004
0005
0006
0007 #if !defined(BOOST_FUSION_SEGMENTED_FIND_IF_HPP_INCLUDED)
0008 #define BOOST_FUSION_SEGMENTED_FIND_IF_HPP_INCLUDED
0009
0010 #include <boost/fusion/support/config.hpp>
0011 #include <boost/mpl/eval_if.hpp>
0012 #include <boost/mpl/identity.hpp>
0013 #include <boost/fusion/algorithm/query/find_if_fwd.hpp>
0014 #include <boost/fusion/iterator/equal_to.hpp>
0015 #include <boost/fusion/sequence/intrinsic/end.hpp>
0016 #include <boost/fusion/support/segmented_fold_until.hpp>
0017
0018 namespace boost { namespace fusion { namespace detail
0019 {
0020 template <typename Pred>
0021 struct segmented_find_if_fun
0022 {
0023 template <typename Sequence, typename State, typename Context>
0024 struct apply
0025 {
0026 typedef
0027 typename result_of::find_if<Sequence, Pred>::type
0028 iterator_type;
0029
0030 typedef
0031 typename result_of::equal_to<
0032 iterator_type
0033 , typename result_of::end<Sequence>::type
0034 >::type
0035 continue_type;
0036
0037 typedef
0038 typename mpl::eval_if<
0039 continue_type
0040 , mpl::identity<State>
0041 , result_of::make_segmented_iterator<
0042 iterator_type
0043 , Context
0044 >
0045 >::type
0046 type;
0047
0048 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0049 static type call(Sequence& seq, State const&state, Context const& context, segmented_find_if_fun)
0050 {
0051 return call_impl(seq, state, context, continue_type());
0052 }
0053
0054 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0055 static type call_impl(Sequence&, State const&state, Context const&, mpl::true_)
0056 {
0057 return state;
0058 }
0059
0060 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0061 static type call_impl(Sequence& seq, State const&, Context const& context, mpl::false_)
0062 {
0063 return fusion::make_segmented_iterator(fusion::find_if<Pred>(seq), context);
0064 }
0065 };
0066 };
0067
0068 template <typename Sequence, typename Pred>
0069 struct result_of_segmented_find_if
0070 {
0071 struct filter
0072 {
0073 typedef
0074 typename result_of::segmented_fold_until<
0075 Sequence
0076 , typename result_of::end<Sequence>::type
0077 , segmented_find_if_fun<Pred>
0078 >::type
0079 type;
0080
0081 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0082 static type call(Sequence& seq)
0083 {
0084 return fusion::segmented_fold_until(
0085 seq
0086 , fusion::end(seq)
0087 , segmented_find_if_fun<Pred>());
0088 }
0089 };
0090
0091 typedef typename filter::type type;
0092 };
0093 }}}
0094
0095 #endif