]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | /*============================================================================= |
2 | Copyright (c) 2003 Jonathan de Halleux (dehalleux@pelikhan.com) | |
3 | http://spirit.sourceforge.net/ | |
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_SPIRIT_ACTOR_DECREMENT_ACTOR_HPP | |
9 | #define BOOST_SPIRIT_ACTOR_DECREMENT_ACTOR_HPP | |
10 | ||
11 | #include <boost/spirit/home/classic/namespace.hpp> | |
12 | #include <boost/spirit/home/classic/actor/ref_actor.hpp> | |
13 | ||
14 | namespace boost { namespace spirit { | |
15 | ||
16 | BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN | |
17 | ||
18 | /////////////////////////////////////////////////////////////////////////// | |
19 | // Summary: | |
20 | // A semantic action policy that calls the -- operator on a reference. | |
21 | // (This doc uses convention available in actors.hpp) | |
22 | // | |
23 | // Actions: | |
24 | // --ref; | |
25 | // | |
26 | // Policy name: | |
27 | // decrement_action | |
28 | // | |
29 | // Policy holder, corresponding helper method: | |
30 | // ref_actor, decrement_a( ref ); | |
31 | // | |
32 | // () operators: both. | |
33 | // | |
34 | // See also ref_actor for more details. | |
35 | /////////////////////////////////////////////////////////////////////////// | |
36 | struct decrement_action | |
37 | { | |
38 | template< | |
39 | typename T | |
40 | > | |
41 | void act(T& ref_) const | |
42 | { | |
43 | --ref_; | |
44 | } | |
45 | }; | |
46 | ||
47 | /////////////////////////////////////////////////////////////////////////// | |
48 | // helper method that creates a and_assign_actor. | |
49 | /////////////////////////////////////////////////////////////////////////// | |
50 | template<typename T> | |
51 | inline ref_actor<T,decrement_action> decrement_a(T& ref_) | |
52 | { | |
53 | return ref_actor<T,decrement_action>(ref_); | |
54 | } | |
55 | ||
56 | BOOST_SPIRIT_CLASSIC_NAMESPACE_END | |
57 | ||
58 | }} | |
59 | ||
60 | #endif |