decrement_actor.hpp 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /*=============================================================================
  2. Copyright (c) 2003 Jonathan de Halleux (dehalleux@pelikhan.com)
  3. http://spirit.sourceforge.net/
  4. Distributed under the Boost Software License, Version 1.0. (See accompanying
  5. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. =============================================================================*/
  7. #ifndef BOOST_SPIRIT_ACTOR_DECREMENT_ACTOR_HPP
  8. #define BOOST_SPIRIT_ACTOR_DECREMENT_ACTOR_HPP
  9. #include <boost/spirit/home/classic/namespace.hpp>
  10. #include <boost/spirit/home/classic/actor/ref_actor.hpp>
  11. namespace boost { namespace spirit {
  12. BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN
  13. ///////////////////////////////////////////////////////////////////////////
  14. // Summary:
  15. // A semantic action policy that calls the -- operator on a reference.
  16. // (This doc uses convention available in actors.hpp)
  17. //
  18. // Actions:
  19. // --ref;
  20. //
  21. // Policy name:
  22. // decrement_action
  23. //
  24. // Policy holder, corresponding helper method:
  25. // ref_actor, decrement_a( ref );
  26. //
  27. // () operators: both.
  28. //
  29. // See also ref_actor for more details.
  30. ///////////////////////////////////////////////////////////////////////////
  31. struct decrement_action
  32. {
  33. template<
  34. typename T
  35. >
  36. void act(T& ref_) const
  37. {
  38. --ref_;
  39. }
  40. };
  41. ///////////////////////////////////////////////////////////////////////////
  42. // helper method that creates a and_assign_actor.
  43. ///////////////////////////////////////////////////////////////////////////
  44. template<typename T>
  45. inline ref_actor<T,decrement_action> decrement_a(T& ref_)
  46. {
  47. return ref_actor<T,decrement_action>(ref_);
  48. }
  49. BOOST_SPIRIT_CLASSIC_NAMESPACE_END
  50. }}
  51. #endif