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_FOR_HPP
9 #define BOOST_PHOENIX_STATEMENT_FOR_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)(for_)
18 , (meta_grammar) // Cond
19 (meta_grammar) // Init
20 (meta_grammar) // Step
24 namespace boost { namespace phoenix
28 typedef void result_type;
46 for(boost::phoenix::eval(init, ctx); boost::phoenix::eval(cond, ctx); boost::phoenix::eval(step, ctx))
47 boost::phoenix::eval(do_it, ctx);
51 template <typename Dummy>
52 struct default_actions::when<rule::for_, Dummy>
53 : call<for_eval, Dummy>
56 template <typename Init, typename Cond, typename Step>
59 for_gen(Init const& init_, Cond const& cond_, Step const& step_)
60 : init(init_), cond(cond_), step(step_) {}
62 template <typename Do>
63 typename expression::for_<Init, Cond, Step, Do>::type const
64 operator[](Do const& do_it) const
68 for_<Init, Cond, Step, Do>::
69 make(init, cond, step, do_it);
77 template <typename Init, typename Cond, typename Step>
79 for_gen<Init, Cond, Step> const
80 for_(Init const& init, Cond const& cond, Step const& step)
82 return for_gen<Init, Cond, Step>(init, cond, step);