bind_helpers.hpp 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. : public std::binary_function<_Ty, _Tz, _Ty>
  19. {
  20. // functor for operator+
  21. _Ty operator()( _Ty _Left, _Tz _Right) const
  22. {
  23. // apply operator+ to operands
  24. return (_Left + _Right);
  25. }
  26. };
  27. // helper to dereference a pointer to a function pointer
  28. template <class T>
  29. struct deref
  30. {
  31. typedef T& result_type;
  32. T& operator()(T* f) const
  33. {
  34. return *f;
  35. }
  36. };
  37. } } }//boost::msm::back
  38. #endif //BOOST_MSM_BACK_BIND_HELPERS_H