Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-27 09:54:58

0001 /*=============================================================================
0002     Copyright (c) 2003 Jonathan de Halleux (dehalleux@pelikhan.com)
0003     http://spirit.sourceforge.net/
0004 
0005   Distributed under the Boost Software License, Version 1.0. (See accompanying
0006   file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0007 =============================================================================*/
0008 #ifndef BOOST_SPIRIT_ACTOR_ERASE_ACTOR_HPP
0009 #define BOOST_SPIRIT_ACTOR_ERASE_ACTOR_HPP
0010 
0011 #include <boost/spirit/home/classic/namespace.hpp>
0012 #include <boost/spirit/home/classic/actor/ref_value_actor.hpp>
0013 #include <boost/spirit/home/classic/actor/ref_const_ref_actor.hpp>
0014 
0015 namespace boost { namespace spirit {
0016 
0017 BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN
0018 
0019     ///////////////////////////////////////////////////////////////////////////
0020     //  Summary:
0021     //  A semantic action policy that calss the erase method.
0022     //  (This doc uses convention available in actors.hpp)
0023     //
0024     //  Actions (what it does):
0025     //      ref.erase( value );
0026     //      ref.erase( T::key_type(first,last) );
0027     //      ref.erase( key_ref );
0028     //
0029     //  Policy name:
0030     //      erase_action
0031     //
0032     //  Policy holder, corresponding helper method:
0033     //      ref_value_actor, erase_a( ref );
0034     //      ref_const_ref_actor, erase_a( ref, key_ref );
0035     //
0036     //  () operators: both
0037     //
0038     //  See also ref_value_actor and ref_const_ref_actor for more details.
0039     ///////////////////////////////////////////////////////////////////////////
0040     struct erase_action
0041     {
0042         template<
0043             typename T,
0044             typename KeyT
0045         >
0046         void act(T& ref_, KeyT const& key_) const
0047         {
0048             ref_.erase(key_);
0049         }
0050         template<
0051             typename T,
0052             typename IteratorT
0053         >
0054         void act(
0055             T& ref_,
0056             IteratorT const& first_,
0057             IteratorT const& last_
0058             ) const
0059         {
0060             typedef typename T::key_type key_type;
0061             key_type key(first_,last_);
0062 
0063             ref_.erase(key);
0064         }
0065     };
0066 
0067     template<typename T>
0068     inline ref_value_actor<T,erase_action> erase_a(T& ref_)
0069     {
0070         return ref_value_actor<T,erase_action>(ref_);
0071     }
0072 
0073     template<
0074         typename T,
0075         typename KeyT
0076     >
0077     inline ref_const_ref_actor<T,KeyT,erase_action> erase_a(
0078         T& ref_,
0079         KeyT const& key_
0080     )
0081     {
0082         return ref_const_ref_actor<T,KeyT,erase_action>(ref_,key_);
0083     }
0084 
0085 BOOST_SPIRIT_CLASSIC_NAMESPACE_END
0086 
0087 }}
0088 
0089 #endif