comparison DEPENDENCIES/generic/include/boost/spirit/home/phoenix/statement/for.hpp @ 16:2665513ce2d3

Add boost headers
author Chris Cannam
date Tue, 05 Aug 2014 11:11:38 +0100
parents
children
comparison
equal deleted inserted replaced
15:663ca0da4350 16:2665513ce2d3
1 /*=============================================================================
2 Copyright (c) 2001-2007 Joel de Guzman
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 #ifndef PHOENIX_STATEMENT_FOR_HPP
8 #define PHOENIX_STATEMENT_FOR_HPP
9
10 #include <boost/spirit/home/phoenix/core/composite.hpp>
11 #include <boost/spirit/home/phoenix/core/compose.hpp>
12
13 namespace boost { namespace phoenix
14 {
15 struct for_eval
16 {
17 template <
18 typename Env
19 , typename Init, typename Cond, typename Step, typename Do>
20 struct result
21 {
22 typedef void type;
23 };
24
25 template <
26 typename RT, typename Env
27 , typename Init, typename Cond, typename Step, typename Do>
28 static void
29 eval(
30 Env const& env
31 , Init& init, Cond& cond, Step& step, Do& do_)
32 {
33 for (init.eval(env); cond.eval(env); step.eval(env))
34 do_.eval(env);
35 }
36 };
37
38 template <typename Init, typename Cond, typename Step>
39 struct for_gen
40 {
41 for_gen(Init const& init, Cond const& cond, Step const& step)
42 : init(init), cond(cond), step(step) {}
43
44 template <typename Do>
45 actor<typename as_composite<for_eval, Init, Cond, Step, Do>::type>
46 operator[](Do const& do_) const
47 {
48 return compose<for_eval>(init, cond, step, do_);
49 }
50
51 Init init;
52 Cond cond;
53 Step step;
54 };
55
56 template <typename Init, typename Cond, typename Step>
57 inline for_gen<Init, Cond, Step>
58 for_(Init const& init, Cond const& cond, Step const& step)
59 {
60 return for_gen<Init, Cond, Step>(init, cond, step);
61 }
62 }}
63
64 #endif