bind_helpers.hpp 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. // Copyright 2008 Christophe Henry
  2. // henry UNDERSCORE christophe AT hotmail DOT com
  3. // This is an extended version of the state machine available in the boost::mpl library
  4. // Distributed under the same license as the original.
  5. // Copyright for the original version:
  6. // Copyright 2005 David Abrahams and Aleksey Gurtovoy. Distributed
  7. // under the Boost Software License, Version 1.0. (See accompanying
  8. // file LICENSE_1_0.txt or copy at
  9. // http://www.boost.org/LICENSE_1_0.txt)
  10. #ifndef BOOST_MSM_BACK_BIND_HELPERS_H
  11. #define BOOST_MSM_BACK_BIND_HELPERS_H
  12. #include <functional>
  13. namespace boost { namespace msm { namespace back
  14. {
  15. // helper to replace std::plus as the lack of implicit conversion makes it not usable in one of our bind
  16. template<class _Ty,class _Tz>
  17. struct plus2
  18. {
  19. typedef _Ty first_argument_type;
  20. typedef _Tz second_argument_type;
  21. typedef _Ty result_type;
  22. // functor for operator+
  23. _Ty operator()( _Ty _Left, _Tz _Right) const
  24. {
  25. // apply operator+ to operands
  26. return (_Left + _Right);
  27. }
  28. };
  29. // helper to dereference a pointer to a function pointer
  30. template <class T>
  31. struct deref
  32. {
  33. typedef T& result_type;
  34. T& operator()(T* f) const
  35. {
  36. return *f;
  37. }
  38. };
  39. } } }//boost::msm::back
  40. #endif //BOOST_MSM_BACK_BIND_HELPERS_H