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_ASSIGN_ACTOR_HPP
0009 #define BOOST_SPIRIT_ACTOR_ASSIGN_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 applies the assignment operator.
0022     //  (This doc uses convention available in actors.hpp)
0023     //
0024     //  Actions (what it does):
0025     //      ref = value;
0026     //      ref = T(first,last);
0027     //      ref = value_ref;
0028     //
0029     //  Policy name:
0030     //      assign_action
0031     //
0032     //  Policy holder, corresponding helper method:
0033     //      ref_value_actor, assign_a( ref );
0034     //      ref_const_ref_actor, assign_a( ref, value_ref );
0035     //
0036     //  () operators: both
0037     //
0038     //  See also ref_value_actor and ref_const_ref_actor for more details.
0039     ///////////////////////////////////////////////////////////////////////////
0040     struct assign_action
0041     {
0042         template<
0043             typename T,
0044             typename ValueT
0045         >
0046         void act(T& ref_, ValueT const& value_) const
0047         {
0048             ref_ = value_;
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 T value_type;
0061 #ifndef BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS
0062             value_type value(first_,last_);
0063 #else
0064             value_type value;
0065             std::copy(first_, last_, std::inserter(value, value.end()));
0066 #endif
0067             ref_ = value;
0068         }
0069     };
0070 
0071     // Deprecated. Please use assign_a
0072     template<typename T>
0073     inline ref_value_actor<T,assign_action> assign(T& ref_)
0074     {
0075         return ref_value_actor<T,assign_action>(ref_);
0076     }
0077 
0078     template<typename T>
0079     inline ref_value_actor<T,assign_action> assign_a(T& ref_)
0080     {
0081         return ref_value_actor<T,assign_action>(ref_);
0082     }
0083 
0084     template<
0085         typename T,
0086         typename ValueT
0087     >
0088     inline ref_const_ref_actor<T,ValueT,assign_action> assign_a(
0089         T& ref_,
0090         ValueT const& value_
0091     )
0092     {
0093         return ref_const_ref_actor<T,ValueT,assign_action>(ref_,value_);
0094     }
0095 
0096 BOOST_SPIRIT_CLASSIC_NAMESPACE_END
0097 
0098 }}
0099 
0100 #endif