1 /*=============================================================================
2 Copyright (c) 2011 Eric Niebler
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_FOLD_S_HPP_INCLUDED)
8 #define BOOST_FUSION_FOLD_S_HPP_INCLUDED
10 #include <boost/fusion/support/config.hpp>
11 #include <boost/fusion/algorithm/iteration/fold_fwd.hpp>
12 #include <boost/fusion/support/segmented_fold_until.hpp>
13 #include <boost/mpl/bool.hpp>
15 namespace boost { namespace fusion { namespace detail
17 template <typename Fun>
18 struct segmented_fold_fun
20 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
21 explicit segmented_fold_fun(Fun const& f)
27 template <typename Sequence, typename State, typename Context>
30 typedef typename result_of::fold<Sequence, State, Fun>::type type;
31 typedef mpl::true_ continue_type;
33 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
34 static type call(Sequence& seq, State const& state, Context const&, segmented_fold_fun const& fun)
36 return fusion::fold(seq, state, fun.fun);
41 // The default implementation of this lives in detail/fold.hpp
42 template <typename Sequence, typename State, typename Fun, bool IsSequence, bool IsSegmented>
43 struct result_of_fold;
45 template <typename Sequence, typename State, typename Fun>
46 struct result_of_fold<Sequence, State, Fun, true, true>
49 typename result_of::segmented_fold_until<
52 segmented_fold_fun<Fun>
56 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
57 static type call(Sequence& seq, State& state, Fun& fun)
59 return fusion::segmented_fold_until(seq, state, segmented_fold_fun<Fun>(fun));