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#ifdef _MSC_VER
17# pragma warning(push)
18# pragma warning(disable: 4512) // assignment operator could not be generated.
19#endif
20
21namespace boost { namespace fusion { namespace detail
22{
23 template <typename Fun>
24 struct segmented_for_each_fun
25 {
26 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
27 explicit segmented_for_each_fun(Fun& f)
28 : fun(f)
29 {}
30
31 Fun& fun;
32
33 template <typename Sequence, typename State, typename Context>
34 struct apply
35 {
36 typedef void_ type;
37 typedef mpl::true_ continue_type;
38
39 BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
40 static type call(Sequence& seq, State const&, Context const&, segmented_for_each_fun const& fun)
41 {
42 fusion::for_each(seq, fun.fun);
43 return void_();
44 }
45 };
46 };
47
48 template <typename Sequence, typename F>
49 BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
50 inline void
51 for_each(Sequence& seq, F& f, mpl::true_) // segmented implementation
52 {
53 fusion::segmented_fold_until(seq, void_(), segmented_for_each_fun<F>(f));
54 }
55}}}
56
57#ifdef _MSC_VER
58# pragma warning(pop)
59#endif
60
61#endif
62