~ubuntu-branches/debian/sid/boost1.49/sid

« back to all changes in this revision

Viewing changes to boost/spirit/home/phoenix/statement/while.hpp

  • Committer: Package Import Robot
  • Author(s): Steve M. Robbins
  • Date: 2012-02-26 00:31:44 UTC
  • Revision ID: package-import@ubuntu.com-20120226003144-eaytp12cbf6ubpms
Tags: upstream-1.49.0
ImportĀ upstreamĀ versionĀ 1.49.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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_WHILE_HPP
 
8
#define PHOENIX_STATEMENT_WHILE_HPP
 
9
 
 
10
#include <boost/spirit/home/phoenix/core/composite.hpp>
 
11
#include <boost/spirit/home/phoenix/core/compose.hpp>
 
12
 
 
13
namespace boost { namespace phoenix
 
14
{
 
15
    struct 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
            while (cond.eval(env))
 
28
                do_.eval(env);
 
29
        }
 
30
    };
 
31
 
 
32
    template <typename Cond>
 
33
    struct while_gen
 
34
    {
 
35
        while_gen(Cond const& cond)
 
36
            : cond(cond) {}
 
37
 
 
38
        template <typename Do>
 
39
        actor<typename as_composite<while_eval, Cond, Do>::type>
 
40
        operator[](Do const& do_) const
 
41
        {
 
42
            return compose<while_eval>(cond, do_);
 
43
        }
 
44
 
 
45
        Cond cond;
 
46
    };
 
47
 
 
48
    template <typename Cond>
 
49
    inline while_gen<Cond>
 
50
    while_(Cond const& cond)
 
51
    {
 
52
        return while_gen<Cond>(cond);
 
53
    }
 
54
}}
 
55
 
 
56
#endif