Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-31 10:01:52

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_SWAP_ACTOR_HPP
0009 #define BOOST_SPIRIT_ACTOR_SWAP_ACTOR_HPP
0010 
0011 #include <boost/spirit/home/classic/namespace.hpp>
0012 #include <boost/spirit/home/classic/actor/ref_value_actor.hpp>
0013 
0014 namespace boost { namespace spirit {
0015 
0016 BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN
0017 
0018     ///////////////////////////////////////////////////////////////////////////
0019     //  Summary:
0020     //  A semantic action policy that swaps values.
0021     //  (This doc uses convention available in actors.hpp)
0022     //
0023     //  Actions (what it does):
0024     //      ref.swap( value_ref );
0025     //
0026     //  Policy name:
0027     //      swap_action
0028     //
0029     //  Policy holder, corresponding helper method:
0030     //      ref_value_actor, swap_a( ref );
0031     //      ref_const_ref_actor, swap_a( ref, value_ref );
0032     //
0033     //  () operators: both
0034     //
0035     //  See also ref_value_actor and ref_const_ref_actor for more details.
0036     ///////////////////////////////////////////////////////////////////////////
0037     template<
0038         typename T
0039     >
0040     class swap_actor
0041     {
0042     private:
0043         T& ref;
0044         T& swap_ref;
0045 
0046     public:
0047         swap_actor(
0048             T& ref_,
0049             T& swap_ref_)
0050             : ref(ref_), swap_ref(swap_ref_)
0051         {};
0052 
0053         template<typename T2>
0054         void operator()(T2 const& /*val*/) const
0055         {
0056             ref.swap(swap_ref);
0057         }
0058 
0059 
0060         template<typename IteratorT>
0061         void operator()(
0062             IteratorT const& /*first*/,
0063             IteratorT const& /*last*/
0064             ) const
0065         {
0066             ref.swap(swap_ref);
0067         }
0068     };
0069 
0070     template<
0071         typename T
0072     >
0073     inline swap_actor<T> swap_a(
0074         T& ref_,
0075         T& swap_ref_
0076     )
0077     {
0078         return swap_actor<T>(ref_,swap_ref_);
0079     }
0080 
0081 BOOST_SPIRIT_CLASSIC_NAMESPACE_END
0082 
0083 }}
0084 
0085 #endif