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/type_traits/transform_traits.hpp>
14 #include <boost/type_traits/cv_traits.hpp>
15 #include <boost/type_traits/is_void.hpp>
16 #include <boost/detail/workaround.hpp>
17 #include <boost/type.hpp>
19 #if defined(BOOST_PYTHON_TRACE_REGISTRY) \
20 || defined(BOOST_PYTHON_CONVERTER_REGISTRY_APPLE_MACH_WORKAROUND)
26 // You'll see shared_ptr mentioned in this header because we need to
27 // note which types are shared_ptrs in their registrations, to
28 // implement special shared_ptr handling for rvalue conversions.
29 template <class T> class shared_ptr;
31 namespace python { namespace converter {
38 struct registered_base
40 static registration const& converters;
46 : detail::registered_base<
47 typename add_reference<
48 typename add_cv<T>::type
54 # if !BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1310))
55 // collapses a few more types to the same static instance. MSVC7.1
56 // fails to strip cv-qualification from array types in typeid. For
57 // some reason we can't use this collapse there or array converters
70 register_shared_ptr0(...)
76 register_shared_ptr0(shared_ptr<T>*)
78 registry::lookup_shared_ptr(type_id<shared_ptr<T> >());
81 #if __cplusplus >= 201103L
84 register_shared_ptr0(std::shared_ptr<T>*)
86 registry::lookup_shared_ptr(type_id<std::shared_ptr<T> >());
92 register_shared_ptr1(T const volatile*)
94 detail::register_shared_ptr0((T*)0);
98 inline registration const&
99 registry_lookup2(T&(*)())
101 detail::register_shared_ptr1((T*)0);
102 return registry::lookup(type_id<T&>());
106 inline registration const&
107 registry_lookup1(type<T>)
109 return registry_lookup2((T(*)())0);
112 inline registration const&
113 registry_lookup1(type<const volatile void>)
115 detail::register_shared_ptr1((void*)0);
116 return registry::lookup(type_id<void>());
120 registration const& registered_base<T>::converters = detail::registry_lookup1(type<T>());
124 }}} // namespace boost::python::converter