member.hpp 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. // Copyright (C) 2009-2012 Lorenzo Caminiti
  2. // Distributed under the Boost Software License, Version 1.0
  3. // (see accompanying file LICENSE_1_0.txt or a copy at
  4. // http://www.boost.org/LICENSE_1_0.txt)
  5. // Home at http://www.boost.org/libs/local_function
  6. #ifndef BOOST_LOCAL_FUNCTION_AUX_MEMBER_HPP_
  7. #define BOOST_LOCAL_FUNCTION_AUX_MEMBER_HPP_
  8. namespace boost { namespace local_function { namespace aux {
  9. // Metafunctions to manipulate data members.
  10. template<typename T> struct member_type {
  11. typedef T& reference;
  12. typedef T* pointer;
  13. };
  14. template<typename T> struct member_type<T*> {
  15. typedef T*& reference;
  16. typedef T* pointer;
  17. };
  18. template<typename T> struct member_type<T* const> {
  19. typedef T* const& reference;
  20. typedef T* pointer;
  21. };
  22. template<typename T> struct member_type<T const*> {
  23. typedef T const*& reference;
  24. typedef T const* pointer;
  25. };
  26. template<typename T> struct member_type<T const* const> {
  27. typedef T const* const& reference;
  28. typedef T const* pointer;
  29. };
  30. // NOTE: Do not add specializations for T const[&/*] (ambiguous on VACPP).
  31. template<typename T> T* member_addr(T& data) { return &data; }
  32. template<typename T> T* member_addr(T* data) { return data; }
  33. // NOTE: Do not add specializations for T const[&/*] (ambiguous on VACPP).
  34. template<typename T> T& member_deref(T& data) { return data; }
  35. template<typename T> T& member_deref(T* data) { return *data; }
  36. } } } // namespace
  37. #endif // #include guard