property.hpp 781 B

123456789101112131415161718192021222324252627282930313233
  1. // Copyright Daniel Wallin 2008. Use, modification and distribution is
  2. // subject to the Boost Software License, Version 1.0. (See accompanying
  3. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  4. #ifndef LUABIND_PROPERTY_081020_HPP
  5. # define LUABIND_PROPERTY_081020_HPP
  6. namespace luabind { namespace detail {
  7. template <class Class, class T, class Result = T>
  8. struct access_member_ptr
  9. {
  10. access_member_ptr(T Class::* mem_ptr)
  11. : mem_ptr(mem_ptr)
  12. {}
  13. Result operator()(Class const& x) const
  14. {
  15. return const_cast<Class&>(x).*mem_ptr;
  16. }
  17. void operator()(Class& x, T const& value) const
  18. {
  19. x.*mem_ptr = value;
  20. }
  21. T Class::* mem_ptr;
  22. };
  23. }} // namespace luabind::detail
  24. #endif // LUABIND_PROPERTY_081020_HPP