source: NonGTP/Boost/boost/spirit/actor/erase_actor.hpp @ 857

Revision 857, 2.5 KB checked in by igarcia, 19 years ago (diff)
Line 
1/*=============================================================================
2    Copyright (c) 2003 Jonathan de Halleux (dehalleux@pelikhan.com)
3    http://spirit.sourceforge.net/
4
5    Use, modification and distribution is subject to the Boost Software
6    License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
7    http://www.boost.org/LICENSE_1_0.txt)
8=============================================================================*/
9#ifndef BOOST_SPIRIT_ACTOR_ERASE_ACTOR_HPP
10#define BOOST_SPIRIT_ACTOR_ERASE_ACTOR_HPP
11
12#include <boost/spirit/actor/ref_value_actor.hpp>
13#include <boost/spirit/actor/ref_const_ref_actor.hpp>
14
15namespace boost { namespace spirit {
16
17    ///////////////////////////////////////////////////////////////////////////
18    //  Summary:
19    //  A semantic action policy that calss the erase method.
20    //  (This doc uses convention available in actors.hpp)
21    //
22    //  Actions (what it does):
23    //      ref.erase( value );
24    //      ref.erase( T::key_type(first,last) );
25    //      ref.erase( key_ref );
26    //
27    //  Policy name:
28    //      erase_action
29    //
30    //  Policy holder, corresponding helper method:
31    //      ref_value_actor, erase_a( ref );
32    //      ref_const_ref_actor, erase_a( ref, key_ref );
33    //
34    //  () operators: both
35    //
36    //  See also ref_value_actor and ref_const_ref_actor for more details.
37    ///////////////////////////////////////////////////////////////////////////
38    struct erase_action
39    {
40        template<
41            typename T,
42            typename KeyT
43        >
44        void act(T& ref_, KeyT const& key_) const
45        {
46            ref_.erase(key_);
47        }
48        template<
49            typename T,
50            typename IteratorT
51        >
52        void act(
53            T& ref_,
54            IteratorT const& first_,
55            IteratorT const& last_
56            ) const
57        {
58            typedef typename T::key_type key_type;
59            key_type key(first_,last_);
60
61            ref_.erase(key);
62        }
63    };
64
65    template<typename T>
66    inline ref_value_actor<T,erase_action> erase_a(T& ref_)
67    {
68        return ref_value_actor<T,erase_action>(ref_);
69    }
70
71    template<
72        typename T,
73        typename KeyT
74    >
75    inline ref_const_ref_actor<T,KeyT,erase_action> erase_a(
76        T& ref_,
77        KeyT const& key_
78    )
79    {
80        return ref_const_ref_actor<T,KeyT,erase_action>(ref_,key_);
81    }
82
83}}
84
85#endif
Note: See TracBrowser for help on using the repository browser.