]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/fusion/algorithm/iteration/detail/segmented_for_each.hpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / boost / fusion / algorithm / iteration / detail / segmented_for_each.hpp
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_FOR_EACH_HPP_INCLUDED)
8 #define BOOST_FUSION_SEGMENTED_FOR_EACH_HPP_INCLUDED
9
10 #include <boost/fusion/support/config.hpp>
11 #include <boost/mpl/bool.hpp>
12 #include <boost/fusion/support/void.hpp>
13 #include <boost/fusion/algorithm/iteration/for_each_fwd.hpp>
14 #include <boost/fusion/support/segmented_fold_until.hpp>
15
16 namespace boost { namespace fusion { namespace detail
17 {
18 template <typename Fun>
19 struct segmented_for_each_fun
20 {
21 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
22 explicit segmented_for_each_fun(Fun& f)
23 : fun(f)
24 {}
25
26 Fun& fun;
27
28 template <typename Sequence, typename State, typename Context>
29 struct apply
30 {
31 typedef void_ type;
32 typedef mpl::true_ continue_type;
33
34 BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
35 static type call(Sequence& seq, State const&, Context const&, segmented_for_each_fun const& fun)
36 {
37 fusion::for_each(seq, fun.fun);
38 return void_();
39 }
40 };
41 };
42
43 template <typename Sequence, typename F>
44 BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
45 inline void
46 for_each(Sequence& seq, F& f, mpl::true_) // segmented implementation
47 {
48 fusion::segmented_fold_until(seq, void_(), segmented_for_each_fun<F>(f));
49 }
50 }}}
51
52 #endif