Chris@16
|
1 /*=============================================================================
|
Chris@16
|
2 Copyright (c) 2001-2007 Joel de Guzman
|
Chris@16
|
3
|
Chris@16
|
4 Distributed under the Boost Software License, Version 1.0. (See accompanying
|
Chris@16
|
5 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
6 ==============================================================================*/
|
Chris@16
|
7 #ifndef PHOENIX_STATEMENT_WHILE_HPP
|
Chris@16
|
8 #define PHOENIX_STATEMENT_WHILE_HPP
|
Chris@16
|
9
|
Chris@16
|
10 #include <boost/spirit/home/phoenix/core/composite.hpp>
|
Chris@16
|
11 #include <boost/spirit/home/phoenix/core/compose.hpp>
|
Chris@16
|
12
|
Chris@16
|
13 namespace boost { namespace phoenix
|
Chris@16
|
14 {
|
Chris@16
|
15 struct while_eval
|
Chris@16
|
16 {
|
Chris@16
|
17 template <typename Env, typename Cond, typename Do>
|
Chris@16
|
18 struct result
|
Chris@16
|
19 {
|
Chris@16
|
20 typedef void type;
|
Chris@16
|
21 };
|
Chris@16
|
22
|
Chris@16
|
23 template <typename RT, typename Env, typename Cond, typename Do>
|
Chris@16
|
24 static void
|
Chris@16
|
25 eval(Env const& env, Cond& cond, Do& do_)
|
Chris@16
|
26 {
|
Chris@16
|
27 while (cond.eval(env))
|
Chris@16
|
28 do_.eval(env);
|
Chris@16
|
29 }
|
Chris@16
|
30 };
|
Chris@16
|
31
|
Chris@16
|
32 template <typename Cond>
|
Chris@16
|
33 struct while_gen
|
Chris@16
|
34 {
|
Chris@16
|
35 while_gen(Cond const& cond)
|
Chris@16
|
36 : cond(cond) {}
|
Chris@16
|
37
|
Chris@16
|
38 template <typename Do>
|
Chris@16
|
39 actor<typename as_composite<while_eval, Cond, Do>::type>
|
Chris@16
|
40 operator[](Do const& do_) const
|
Chris@16
|
41 {
|
Chris@16
|
42 return compose<while_eval>(cond, do_);
|
Chris@16
|
43 }
|
Chris@16
|
44
|
Chris@16
|
45 Cond cond;
|
Chris@16
|
46 };
|
Chris@16
|
47
|
Chris@16
|
48 template <typename Cond>
|
Chris@16
|
49 inline while_gen<Cond>
|
Chris@16
|
50 while_(Cond const& cond)
|
Chris@16
|
51 {
|
Chris@16
|
52 return while_gen<Cond>(cond);
|
Chris@16
|
53 }
|
Chris@16
|
54 }}
|
Chris@16
|
55
|
Chris@16
|
56 #endif
|