PageRenderTime 24ms CodeModel.GetById 14ms app.highlight 6ms RepoModel.GetById 2ms app.codeStats 0ms

/src/contrib/boost/spirit/home/phoenix/statement/do_while.hpp

http://pythonocc.googlecode.com/
C++ Header | 62 lines | 47 code | 9 blank | 6 comment | 1 complexity | 8293973d5e124a5b4c86f5d4c70be93d MD5 | raw file
 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_DO_WHILE_HPP
 8#define PHOENIX_STATEMENT_DO_WHILE_HPP
 9
10#include <boost/spirit/home/phoenix/core/composite.hpp>
11#include <boost/spirit/home/phoenix/core/compose.hpp>
12
13namespace boost { namespace phoenix
14{
15    struct do_while_eval
16    {
17        template <typename Env, typename Cond, typename Do>
18        struct result
19        {
20            typedef void type;
21        };
22
23        template <typename RT, typename Env, typename Cond, typename Do>
24        static void
25        eval(Env const& env, Cond& cond, Do& do_)
26        {
27            do
28                do_.eval(env);
29            while (cond.eval(env));
30        }
31    };
32
33    template <typename Do>
34    struct do_while_gen
35    {
36        do_while_gen(Do const& do_)
37            : do_(do_) {}
38
39        template <typename Cond>
40        actor<typename as_composite<do_while_eval, Cond, Do>::type>
41        while_(Cond const& cond) const
42        {
43            return compose<do_while_eval>(cond, do_);
44        }
45
46        Do do_;
47    };
48
49    struct do_gen
50    {
51        template <typename Do>
52        do_while_gen<Do>
53        operator[](Do const& do_) const
54        {
55            return do_while_gen<Do>(do_);
56        }
57    };
58
59    do_gen const do_ = do_gen();
60}}
61
62#endif