]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/fusion/include/boost/fusion/algorithm/iteration/detail/segmented_fold.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / fusion / include / boost / fusion / algorithm / iteration / detail / segmented_fold.hpp
CommitLineData
7c673cae
FG
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_FOLD_S_HPP_INCLUDED)
8#define BOOST_FUSION_FOLD_S_HPP_INCLUDED
9
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>
14
15namespace boost { namespace fusion { namespace detail
16{
17 template <typename Fun>
18 struct segmented_fold_fun
19 {
20 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
21 explicit segmented_fold_fun(Fun const& f)
22 : fun(f)
23 {}
24
25 Fun const& fun;
26
27 template <typename Sequence, typename State, typename Context>
28 struct apply
29 {
30 typedef typename result_of::fold<Sequence, State, Fun>::type type;
31 typedef mpl::true_ continue_type;
32
33 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
34 static type call(Sequence& seq, State const& state, Context const&, segmented_fold_fun const& fun)
35 {
36 return fusion::fold(seq, state, fun.fun);
37 }
38 };
39 };
40
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;
44
45 template <typename Sequence, typename State, typename Fun>
46 struct result_of_fold<Sequence, State, Fun, true, true>
47 {
48 typedef
49 typename result_of::segmented_fold_until<
50 Sequence,
51 State,
52 segmented_fold_fun<Fun>
53 >::type
54 type;
55
56 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
57 static type call(Sequence& seq, State& state, Fun& fun)
58 {
59 return fusion::segmented_fold_until(seq, state, segmented_fold_fun<Fun>(fun));
60 }
61 };
62}}}
63
64#endif