Mercurial > hg > vamp-build-and-test
comparison DEPENDENCIES/generic/include/boost/phoenix/statement/for.hpp @ 16:2665513ce2d3
Add boost headers
author | Chris Cannam |
---|---|
date | Tue, 05 Aug 2014 11:11:38 +0100 |
parents | |
children | c530137014c0 |
comparison
equal
deleted
inserted
replaced
15:663ca0da4350 | 16:2665513ce2d3 |
---|---|
1 /*============================================================================== | |
2 Copyright (c) 2001-2010 Joel de Guzman | |
3 Copyright (c) 2010 Thomas Heller | |
4 | |
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 | |
10 | |
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> | |
15 | |
16 BOOST_PHOENIX_DEFINE_EXPRESSION( | |
17 (boost)(phoenix)(for_) | |
18 , (meta_grammar) // Cond | |
19 (meta_grammar) // Init | |
20 (meta_grammar) // Step | |
21 (meta_grammar) // Do | |
22 ) | |
23 | |
24 namespace boost { namespace phoenix | |
25 { | |
26 struct for_eval | |
27 { | |
28 typedef void result_type; | |
29 | |
30 template < | |
31 typename Init | |
32 , typename Cond | |
33 , typename Step | |
34 , typename Do | |
35 , typename Context | |
36 > | |
37 result_type | |
38 operator()( | |
39 Init const& init | |
40 , Cond const& cond | |
41 , Step const& step | |
42 , Do const& do_ | |
43 , Context const & ctx | |
44 ) const | |
45 { | |
46 for(boost::phoenix::eval(init, ctx); boost::phoenix::eval(cond, ctx); boost::phoenix::eval(step, ctx)) | |
47 boost::phoenix::eval(do_, ctx); | |
48 } | |
49 }; | |
50 | |
51 template <typename Dummy> | |
52 struct default_actions::when<rule::for_, Dummy> | |
53 : call<for_eval, Dummy> | |
54 {}; | |
55 | |
56 template <typename Init, typename Cond, typename Step> | |
57 struct for_gen | |
58 { | |
59 for_gen(Init const& init, Cond const& cond, Step const& step) | |
60 : init(init), cond(cond), step(step) {} | |
61 | |
62 template <typename Do> | |
63 typename expression::for_<Init, Cond, Step, Do>::type const | |
64 operator[](Do const& do_) const | |
65 { | |
66 return | |
67 expression:: | |
68 for_<Init, Cond, Step, Do>:: | |
69 make(init, cond, step, do_); | |
70 } | |
71 | |
72 Init init; | |
73 Cond cond; | |
74 Step step; | |
75 }; | |
76 | |
77 template <typename Init, typename Cond, typename Step> | |
78 inline | |
79 for_gen<Init, Cond, Step> const | |
80 for_(Init const& init, Cond const& cond, Step const& step) | |
81 { | |
82 return for_gen<Init, Cond, Step>(init, cond, step); | |
83 } | |
84 | |
85 }} | |
86 | |
87 #endif |