1 // Copyright David Abrahams 2002.
2 // Copyright Stefan Seefeld 2016.
3 // Distributed under the Boost Software License, Version 1.0. (See
4 // accompanying file LICENSE_1_0.txt or copy at
5 // http://www.boost.org/LICENSE_1_0.txt)
7 #ifndef boost_python_converter_registered_hpp_
8 #define boost_python_converter_registered_hpp_
10 #include <boost/python/type_id.hpp>
11 #include <boost/python/converter/registry.hpp>
12 #include <boost/python/converter/registrations.hpp>
13 #include <boost/python/detail/type_traits.hpp>
14 #include <boost/detail/workaround.hpp>
15 #include <boost/type.hpp>
17 #if defined(BOOST_PYTHON_TRACE_REGISTRY) \
18 || defined(BOOST_PYTHON_CONVERTER_REGISTRY_APPLE_MACH_WORKAROUND)
24 // You'll see shared_ptr mentioned in this header because we need to
25 // note which types are shared_ptrs in their registrations, to
26 // implement special shared_ptr handling for rvalue conversions.
27 template <class T> class shared_ptr;
29 namespace python { namespace converter {
36 struct registered_base
38 static registration const& converters;
44 : detail::registered_base<
45 typename boost::python::detail::add_lvalue_reference<
46 typename boost::python::detail::add_cv<T>::type
52 # if !BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1310))
53 // collapses a few more types to the same static instance. MSVC7.1
54 // fails to strip cv-qualification from array types in typeid. For
55 // some reason we can't use this collapse there or array converters
68 register_shared_ptr0(...)
74 register_shared_ptr0(shared_ptr<T>*)
76 registry::lookup_shared_ptr(type_id<shared_ptr<T> >());
79 #if !defined(BOOST_NO_CXX11_SMART_PTR)
82 register_shared_ptr0(std::shared_ptr<T>*)
84 registry::lookup_shared_ptr(type_id<std::shared_ptr<T> >());
90 register_shared_ptr1(T const volatile*)
92 detail::register_shared_ptr0((T*)0);
96 inline registration const&
97 registry_lookup2(T&(*)())
99 detail::register_shared_ptr1((T*)0);
100 return registry::lookup(type_id<T&>());
104 inline registration const&
105 registry_lookup1(type<T>)
107 return registry_lookup2((T(*)())0);
110 inline registration const&
111 registry_lookup1(type<const volatile void>)
113 detail::register_shared_ptr1((void*)0);
114 return registry::lookup(type_id<void>());
118 registration const& registered_base<T>::converters = detail::registry_lookup1(type<T>());
122 }}} // namespace boost::python::converter