bind_member_variable.hpp 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*=============================================================================
  2. Copyright (c) 2001-2007 Joel de Guzman
  3. Copyright (c) 2014 John Fletcher
  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 PHOENIX_BIND_BIND_MEMBER_VARIABLE_HPP
  8. #define PHOENIX_BIND_BIND_MEMBER_VARIABLE_HPP
  9. #include <boost/utility/enable_if.hpp>
  10. #include <boost/type_traits/is_member_function_pointer.hpp>
  11. #include <boost/phoenix/core/expression.hpp>
  12. #include <boost/phoenix/core/detail/function_eval.hpp>
  13. #include <boost/phoenix/bind/detail/member_variable.hpp>
  14. namespace boost { namespace phoenix
  15. {
  16. template <typename RT, typename ClassT, typename ClassA>
  17. inline
  18. typename boost::lazy_disable_if<
  19. boost::is_member_function_pointer<RT (ClassT::*)>,
  20. typename detail::expression::function_eval<
  21. detail::member_variable<RT, RT ClassT::*>
  22. , ClassA >//::type
  23. >::type const
  24. bind(RT ClassT::*mp, ClassA const& obj)
  25. {
  26. typedef detail::member_variable<RT, RT ClassT::*> mp_type;
  27. return
  28. detail::expression::function_eval<mp_type, ClassA>
  29. ::make(mp_type(mp), obj);
  30. }
  31. template <typename RT, typename ClassT>
  32. inline
  33. typename boost::lazy_disable_if<
  34. boost::is_member_function_pointer<RT (ClassT::*)>,
  35. typename detail::expression::function_eval<
  36. detail::member_variable<RT, RT ClassT::*>
  37. , ClassT >//::type
  38. >::type const
  39. bind(RT ClassT::*mp, ClassT& obj)
  40. {
  41. typedef detail::member_variable<RT, RT ClassT::*> mp_type;
  42. return
  43. detail::expression::function_eval<
  44. mp_type
  45. , ClassT
  46. >::make(mp_type(mp), obj);
  47. }
  48. }}
  49. #endif