manage_new_object.hpp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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 MANAGE_NEW_OBJECT_DWA200222_HPP
  6. # define MANAGE_NEW_OBJECT_DWA200222_HPP
  7. # include <boost/python/detail/prefix.hpp>
  8. # include <boost/python/detail/indirect_traits.hpp>
  9. # include <boost/python/detail/type_traits.hpp>
  10. # include <boost/mpl/if.hpp>
  11. # include <boost/python/to_python_indirect.hpp>
  12. namespace boost { namespace python {
  13. namespace detail
  14. {
  15. template <class R>
  16. struct manage_new_object_requires_a_pointer_return_type
  17. # if defined(__GNUC__) || defined(__EDG__)
  18. {}
  19. # endif
  20. ;
  21. }
  22. struct manage_new_object
  23. {
  24. template <class T>
  25. struct apply
  26. {
  27. typedef typename mpl::if_c<
  28. detail::is_pointer<T>::value
  29. , to_python_indirect<T, detail::make_owning_holder>
  30. , detail::manage_new_object_requires_a_pointer_return_type<T>
  31. >::type type;
  32. };
  33. };
  34. }} // namespace boost::python
  35. #endif // MANAGE_NEW_OBJECT_DWA200222_HPP