reference_existing_object.hpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // Copyright David Abrahams 2002.
  2. // Distributed under the Boost Software License, Version 1.0. (See
  3. // accompanying file LICENSE_1_0.txt or copy at
  4. // http://www.boost.org/LICENSE_1_0.txt)
  5. #ifndef REFERENCE_EXISTING_OBJECT_DWA200222_HPP
  6. # define REFERENCE_EXISTING_OBJECT_DWA200222_HPP
  7. # include <boost/python/detail/prefix.hpp>
  8. # include <boost/python/detail/indirect_traits.hpp>
  9. # include <boost/mpl/if.hpp>
  10. # include <boost/python/to_python_indirect.hpp>
  11. # include <boost/python/detail/type_traits.hpp>
  12. namespace boost { namespace python {
  13. namespace detail
  14. {
  15. template <class R>
  16. struct reference_existing_object_requires_a_pointer_or_reference_return_type
  17. # if defined(__GNUC__) || defined(__EDG__)
  18. {}
  19. # endif
  20. ;
  21. }
  22. template <class T> struct to_python_value;
  23. struct reference_existing_object
  24. {
  25. template <class T>
  26. struct apply
  27. {
  28. BOOST_STATIC_CONSTANT(
  29. bool, ok = detail::is_pointer<T>::value || detail::is_reference<T>::value);
  30. typedef typename mpl::if_c<
  31. ok
  32. , to_python_indirect<T, detail::make_reference_holder>
  33. , detail::reference_existing_object_requires_a_pointer_or_reference_return_type<T>
  34. >::type type;
  35. };
  36. };
  37. }} // namespace boost::python
  38. #endif // REFERENCE_EXISTING_OBJECT_DWA200222_HPP