| 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_FOLD_UNTIL_HPP_INCLUDED) |
| 8 | #define BOOST_FUSION_SEGMENTED_FOLD_UNTIL_HPP_INCLUDED |
| 9 | |
| 10 | #include <boost/fusion/support/config.hpp> |
| 11 | #include <boost/type_traits/is_const.hpp> |
| 12 | #include <boost/utility/enable_if.hpp> |
| 13 | #include <boost/fusion/support/detail/segmented_fold_until_impl.hpp> |
| 14 | |
| 15 | namespace boost { namespace fusion |
| 16 | { |
| 17 | //auto segmented_fold_until(seq, state, fun) |
| 18 | //{ |
| 19 | // return first(segmented_fold_until_impl(seq, state, nil_, fun)); |
| 20 | //} |
| 21 | |
| 22 | namespace result_of |
| 23 | { |
| 24 | template <typename Sequence, typename State, typename Fun> |
| 25 | struct segmented_fold_until |
| 26 | { |
| 27 | typedef |
| 28 | detail::segmented_fold_until_impl< |
| 29 | Sequence |
| 30 | , State |
| 31 | , fusion::nil_ |
| 32 | , Fun |
| 33 | > |
| 34 | filter; |
| 35 | |
| 36 | typedef |
| 37 | typename filter::type |
| 38 | type; |
| 39 | }; |
| 40 | } |
| 41 | |
| 42 | template <typename Sequence, typename State, typename Fun> |
| 43 | BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED |
| 44 | inline typename |
| 45 | lazy_disable_if< |
| 46 | is_const<Sequence> |
| 47 | , result_of::segmented_fold_until<Sequence, State, Fun> |
| 48 | >::type |
| 49 | segmented_fold_until(Sequence& seq, State const& state, Fun const& fun) |
| 50 | { |
| 51 | typedef |
| 52 | typename result_of::segmented_fold_until<Sequence, State, Fun>::filter |
| 53 | filter; |
| 54 | |
| 55 | return filter::call(seq, state, fusion::nil_(), fun); |
| 56 | } |
| 57 | |
| 58 | template <typename Sequence, typename State, typename Fun> |
| 59 | BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED |
| 60 | inline typename result_of::segmented_fold_until<Sequence const, State, Fun>::type |
| 61 | segmented_fold_until(Sequence const& seq, State const& state, Fun const& fun) |
| 62 | { |
| 63 | typedef |
| 64 | typename result_of::segmented_fold_until<Sequence const, State, Fun>::filter |
| 65 | filter; |
| 66 | |
| 67 | return filter::call(seq, state, fusion::nil_(), fun); |
| 68 | } |
| 69 | }} |
| 70 | |
| 71 | #endif |
| 72 | |