]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/spirit/include/boost/spirit/home/classic/actor/push_front_actor.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / spirit / include / boost / spirit / home / classic / actor / push_front_actor.hpp
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_PUSH_FRONT_ACTOR_HPP
9 #define BOOST_SPIRIT_ACTOR_PUSH_FRONT_ACTOR_HPP
10
11 #include <boost/spirit/home/classic/namespace.hpp>
12 #include <boost/spirit/home/classic/actor/ref_value_actor.hpp>
13 #include <boost/spirit/home/classic/actor/ref_const_ref_actor.hpp>
14
15 namespace boost { namespace spirit {
16
17 BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN
18
19 ///////////////////////////////////////////////////////////////////////////
20 // Summary:
21 //
22 // A semantic action policy that appends a value to the front of a
23 // container.
24 // (This doc uses convention available in actors.hpp)
25 //
26 // Actions (what it does and what ref, value_ref must support):
27 // ref.push_front( value );
28 // ref.push_front( T::value_type(first,last) );
29 // ref.push_front( value_ref );
30 //
31 // Policy name:
32 // push_front_action
33 //
34 // Policy holder, corresponding helper method:
35 // ref_value_actor, push_front_a( ref );
36 // ref_const_ref_actor, push_front_a( ref, value_ref );
37 //
38 // () operators: both
39 //
40 // See also ref_value_actor and ref_const_ref_actor for more details.
41 ///////////////////////////////////////////////////////////////////////////
42 struct push_front_action
43 {
44 template<
45 typename T,
46 typename ValueT
47 >
48 void act(T& ref_, ValueT const& value_) const
49 {
50 ref_.push_front( value_ );
51 }
52 template<
53 typename T,
54 typename IteratorT
55 >
56 void act(
57 T& ref_,
58 IteratorT const& first_,
59 IteratorT const& last_
60 ) const
61 {
62 typedef typename T::value_type value_type;
63 value_type value(first_,last_);
64
65 ref_.push_front( value );
66 }
67 };
68
69 template<typename T>
70 inline ref_value_actor<T,push_front_action> push_front_a(T& ref_)
71 {
72 return ref_value_actor<T,push_front_action>(ref_);
73 }
74
75 template<
76 typename T,
77 typename ValueT
78 >
79 inline ref_const_ref_actor<T,ValueT,push_front_action> push_front_a(
80 T& ref_,
81 ValueT const& value_
82 )
83 {
84 return ref_const_ref_actor<T,ValueT,push_front_action>(ref_,value_);
85 }
86
87 BOOST_SPIRIT_CLASSIC_NAMESPACE_END
88
89 }}
90
91 #endif