]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/python/include/boost/python/converter/registered.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / python / include / boost / python / converter / registered.hpp
CommitLineData
7c673cae
FG
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)
6
7#ifndef boost_python_converter_registered_hpp_
8#define boost_python_converter_registered_hpp_
9
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>
18#include <memory>
19#if defined(BOOST_PYTHON_TRACE_REGISTRY) \
20 || defined(BOOST_PYTHON_CONVERTER_REGISTRY_APPLE_MACH_WORKAROUND)
21# include <iostream>
22#endif
23
24namespace boost {
25
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.
29template <class T> class shared_ptr;
30
31namespace python { namespace converter {
32
33struct registration;
34
35namespace detail
36{
37 template <class T>
38 struct registered_base
39 {
40 static registration const& converters;
41 };
42}
43
44template <class T>
45struct registered
46 : detail::registered_base<
47 typename add_reference<
48 typename add_cv<T>::type
49 >::type
50 >
51{
52};
53
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
58// will not be found.
59template <class T>
60struct registered<T&>
61 : registered<T> {};
62# endif
63
64//
65// implementations
66//
67namespace detail
68{
69 inline void
70 register_shared_ptr0(...)
71 {
72 }
73
74 template <class T>
75 inline void
76 register_shared_ptr0(shared_ptr<T>*)
77 {
78 registry::lookup_shared_ptr(type_id<shared_ptr<T> >());
79 }
80
81#if __cplusplus >= 201103L
82 template <class T>
83 inline void
84 register_shared_ptr0(std::shared_ptr<T>*)
85 {
86 registry::lookup_shared_ptr(type_id<std::shared_ptr<T> >());
87 }
88#endif
89
90 template <class T>
91 inline void
92 register_shared_ptr1(T const volatile*)
93 {
94 detail::register_shared_ptr0((T*)0);
95 }
96
97 template <class T>
98 inline registration const&
99 registry_lookup2(T&(*)())
100 {
101 detail::register_shared_ptr1((T*)0);
102 return registry::lookup(type_id<T&>());
103 }
104
105 template <class T>
106 inline registration const&
107 registry_lookup1(type<T>)
108 {
109 return registry_lookup2((T(*)())0);
110 }
111
112 inline registration const&
113 registry_lookup1(type<const volatile void>)
114 {
115 detail::register_shared_ptr1((void*)0);
116 return registry::lookup(type_id<void>());
117 }
118
119 template <class T>
120 registration const& registered_base<T>::converters = detail::registry_lookup1(type<T>());
121
122}
123
124}}} // namespace boost::python::converter
125
126#endif