1 /*==============================================================================
2 Copyright (c) 2001-2010 Joel de Guzman
3 Copyright (c) 2010 Thomas Heller
5 Distributed under the Boost Software License, Version 1.0. (See accompanying
6 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7 ==============================================================================*/
8 #ifndef BOOST_PHOENIX_STATEMENT_WHILE_HPP
9 #define BOOST_PHOENIX_STATEMENT_WHILE_HPP
11 #include <boost/phoenix/core/limits.hpp>
12 #include <boost/phoenix/core/call.hpp>
13 #include <boost/phoenix/core/expression.hpp>
14 #include <boost/phoenix/core/meta_grammar.hpp>
16 BOOST_PHOENIX_DEFINE_EXPRESSION(
17 (boost)(phoenix)(while_)
18 , (meta_grammar) // Cond
22 namespace boost { namespace phoenix
26 typedef void result_type;
28 template <typename Cond, typename Do, typename Context>
30 operator()(Cond const& cond, Do const& do_it, Context const & ctx) const
32 while(boost::phoenix::eval(cond, ctx))
34 boost::phoenix::eval(do_it, ctx);
39 template <typename Dummy>
40 struct default_actions::when<rule::while_, Dummy>
41 : call<while_eval, Dummy>
44 template <typename Cond>
47 while_gen(Cond const& cond_) : cond(cond_) {}
49 template <typename Do>
50 typename expression::while_<Cond, Do>::type const
51 operator[](Do const& do_it) const
53 return expression::while_<Cond, Do>::make(cond, do_it);
59 template <typename Cond>
62 while_(Cond const& cond)
64 return while_gen<Cond>(cond);