12#define PYBIND11_VERSION_MAJOR 2
13#define PYBIND11_VERSION_MINOR 9
14#define PYBIND11_VERSION_PATCH 2
18#define PYBIND11_VERSION_HEX 0x02090200
20#define PYBIND11_NAMESPACE_BEGIN(name) namespace name {
21#define PYBIND11_NAMESPACE_END(name) }
26#if !defined(PYBIND11_NAMESPACE)
28# define PYBIND11_NAMESPACE pybind11 __attribute__((visibility("hidden")))
30# define PYBIND11_NAMESPACE pybind11
34#if !(defined(_MSC_VER) && __cplusplus == 199711L)
35# if __cplusplus >= 201402L
36# define PYBIND11_CPP14
37# if __cplusplus >= 201703L
38# define PYBIND11_CPP17
39# if __cplusplus >= 202002L
40# define PYBIND11_CPP20
44#elif defined(_MSC_VER) && __cplusplus == 199711L
48# if _MSVC_LANG >= 201402L
49# define PYBIND11_CPP14
50# if _MSVC_LANG > 201402L && _MSC_VER >= 1910
51# define PYBIND11_CPP17
52# if _MSVC_LANG >= 202002L
53# define PYBIND11_CPP20
60#if defined(__INTEL_COMPILER)
61# if __INTEL_COMPILER < 1800
62# error pybind11 requires Intel C++ compiler v18 or newer
63# elif __INTEL_COMPILER < 1900 && defined(PYBIND11_CPP14)
64# error pybind11 supports only C++11 with Intel C++ compiler v18. Use v19 or newer for C++14.
68# pragma warning disable 2196
69#elif defined(__clang__) && !defined(__apple_build_version__)
70# if __clang_major__ < 3 || (__clang_major__ == 3 && __clang_minor__ < 3)
71# error pybind11 requires clang 3.3 or newer
73#elif defined(__clang__)
76# if __clang_major__ < 5
77# error pybind11 requires Xcode/clang 5.0 or newer
79#elif defined(__GNUG__)
80# if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 8)
81# error pybind11 requires gcc 4.8 or newer
83#elif defined(_MSC_VER)
86# if _MSC_FULL_VER < 190024210
87# error pybind11 requires MSVC 2015 update 3 or newer
91#if !defined(PYBIND11_EXPORT)
92# if defined(WIN32) || defined(_WIN32)
93# define PYBIND11_EXPORT __declspec(dllexport)
95# define PYBIND11_EXPORT __attribute__((visibility("default")))
99#if !defined(PYBIND11_EXPORT_EXCEPTION)
104# define PYBIND11_EXPORT_EXCEPTION
106# define PYBIND11_EXPORT_EXCEPTION PYBIND11_EXPORT
116#if !defined(PYBIND11_NOINLINE_FORCED) \
117 && (defined(__CUDACC__) || (defined(__GNUC__) && (__GNUC__ == 7 || __GNUC__ == 8)))
118# define PYBIND11_NOINLINE_DISABLED
124#if defined(PYBIND11_NOINLINE_DISABLED)
125# define PYBIND11_NOINLINE inline
126#elif defined(_MSC_VER)
127# define PYBIND11_NOINLINE __declspec(noinline) inline
129# define PYBIND11_NOINLINE __attribute__((noinline)) inline
132#if defined(__MINGW32__)
135# define PYBIND11_DEPRECATED(reason)
136#elif defined(PYBIND11_CPP14)
137# define PYBIND11_DEPRECATED(reason) [[deprecated(reason)]]
139# define PYBIND11_DEPRECATED(reason) __attribute__((deprecated(reason)))
142#if defined(PYBIND11_CPP17)
143# define PYBIND11_MAYBE_UNUSED [[maybe_unused]]
144#elif defined(_MSC_VER) && !defined(__clang__)
145# define PYBIND11_MAYBE_UNUSED
147# define PYBIND11_MAYBE_UNUSED __attribute__((__unused__))
152#if defined(_MSC_VER) && _MSC_VER >= 1900
153# define HAVE_SNPRINTF 1
158# pragma warning(push)
160# pragma warning(disable : 4505)
161# if defined(_DEBUG) && !defined(Py_DEBUG)
167# if _MSVC_STL_VERSION >= 143
170# define PYBIND11_DEBUG_MARKER
176#if defined(__STDC_LIB_EXT1__) && !defined(__STDC_WANT_LIB_EXT1__)
177# define __STDC_WANT_LIB_EXT1__
182# if defined(PYBIND11_CPP17) && __has_include(<optional>)
183# define PYBIND11_HAS_OPTIONAL 1
186# if defined(PYBIND11_CPP14) && (__has_include(<experimental/optional>) && \
187 !__has_include(<optional>))
188# define PYBIND11_HAS_EXP_OPTIONAL 1
191# if defined(PYBIND11_CPP17) && __has_include(<variant>)
192# define PYBIND11_HAS_VARIANT 1
194#elif defined(_MSC_VER) && defined(PYBIND11_CPP17)
195# define PYBIND11_HAS_OPTIONAL 1
196# define PYBIND11_HAS_VARIANT 1
199#if defined(PYBIND11_CPP17)
200# if defined(__has_include)
201# if __has_include(<string_view>)
202# define PYBIND11_HAS_STRING_VIEW
204# elif defined(_MSC_VER)
205# define PYBIND11_HAS_STRING_VIEW
209#if defined(__cpp_lib_char8_t) && __cpp_lib_char8_t >= 201811L
210# define PYBIND11_HAS_U8STRING
214#include <frameobject.h>
235# if defined(PYBIND11_DEBUG_MARKER)
237# undef PYBIND11_DEBUG_MARKER
245#include <forward_list>
249#include <type_traits>
251#include <unordered_map>
252#include <unordered_set>
254#if defined(__has_include)
255# if __has_include(<version>)
273#if PY_MAJOR_VERSION >= 3
274# define PYBIND11_INSTANCE_METHOD_NEW(ptr, class_) PyInstanceMethod_New(ptr)
275# define PYBIND11_INSTANCE_METHOD_CHECK PyInstanceMethod_Check
276# define PYBIND11_INSTANCE_METHOD_GET_FUNCTION PyInstanceMethod_GET_FUNCTION
277# define PYBIND11_BYTES_CHECK PyBytes_Check
278# define PYBIND11_BYTES_FROM_STRING PyBytes_FromString
279# define PYBIND11_BYTES_FROM_STRING_AND_SIZE PyBytes_FromStringAndSize
280# define PYBIND11_BYTES_AS_STRING_AND_SIZE PyBytes_AsStringAndSize
281# define PYBIND11_BYTES_AS_STRING PyBytes_AsString
282# define PYBIND11_BYTES_SIZE PyBytes_Size
283# define PYBIND11_LONG_CHECK(o) PyLong_Check(o)
284# define PYBIND11_LONG_AS_LONGLONG(o) PyLong_AsLongLong(o)
285# define PYBIND11_LONG_FROM_SIGNED(o) PyLong_FromSsize_t((ssize_t) (o))
286# define PYBIND11_LONG_FROM_UNSIGNED(o) PyLong_FromSize_t((size_t) (o))
287# define PYBIND11_BYTES_NAME "bytes"
288# define PYBIND11_STRING_NAME "str"
289# define PYBIND11_SLICE_OBJECT PyObject
290# define PYBIND11_FROM_STRING PyUnicode_FromString
291# define PYBIND11_STR_TYPE ::pybind11::str
292# define PYBIND11_BOOL_ATTR "__bool__"
293# define PYBIND11_NB_BOOL(ptr) ((ptr)->nb_bool)
294# define PYBIND11_BUILTINS_MODULE "builtins"
297# define PYBIND11_PLUGIN_IMPL(name) \
298 extern "C" PYBIND11_MAYBE_UNUSED PYBIND11_EXPORT PyObject *PyInit_##name(); \
299 extern "C" PYBIND11_EXPORT PyObject *PyInit_##name()
302# define PYBIND11_INSTANCE_METHOD_NEW(ptr, class_) PyMethod_New(ptr, nullptr, class_)
303# define PYBIND11_INSTANCE_METHOD_CHECK PyMethod_Check
304# define PYBIND11_INSTANCE_METHOD_GET_FUNCTION PyMethod_GET_FUNCTION
305# define PYBIND11_BYTES_CHECK PyString_Check
306# define PYBIND11_BYTES_FROM_STRING PyString_FromString
307# define PYBIND11_BYTES_FROM_STRING_AND_SIZE PyString_FromStringAndSize
308# define PYBIND11_BYTES_AS_STRING_AND_SIZE PyString_AsStringAndSize
309# define PYBIND11_BYTES_AS_STRING PyString_AsString
310# define PYBIND11_BYTES_SIZE PyString_Size
311# define PYBIND11_LONG_CHECK(o) (PyInt_Check(o) || PyLong_Check(o))
312# define PYBIND11_LONG_AS_LONGLONG(o) \
313 (PyInt_Check(o) ? (long long) PyLong_AsLong(o) : PyLong_AsLongLong(o))
314# define PYBIND11_LONG_FROM_SIGNED(o) PyInt_FromSsize_t((ssize_t) o)
315# define PYBIND11_LONG_FROM_UNSIGNED(o) PyInt_FromSize_t((size_t) o)
316# define PYBIND11_BYTES_NAME "str"
317# define PYBIND11_STRING_NAME "unicode"
318# define PYBIND11_SLICE_OBJECT PySliceObject
319# define PYBIND11_FROM_STRING PyString_FromString
320# define PYBIND11_STR_TYPE ::pybind11::bytes
321# define PYBIND11_BOOL_ATTR "__nonzero__"
322# define PYBIND11_NB_BOOL(ptr) ((ptr)->nb_nonzero)
323# define PYBIND11_BUILTINS_MODULE "__builtin__"
326# define PYBIND11_PLUGIN_IMPL(name) \
327 static PyObject *pybind11_init_wrapper(); \
328 extern "C" PYBIND11_MAYBE_UNUSED PYBIND11_EXPORT void init##name(); \
329 extern "C" PYBIND11_EXPORT void init##name() { (void) pybind11_init_wrapper(); } \
330 PyObject *pybind11_init_wrapper()
333#if PY_VERSION_HEX >= 0x03050000 && PY_VERSION_HEX < 0x03050200
335struct _Py_atomic_address {
338PyAPI_DATA(_Py_atomic_address) _PyThreadState_Current;
342#define PYBIND11_TRY_NEXT_OVERLOAD ((PyObject *) 1)
343#define PYBIND11_STRINGIFY(x) #x
344#define PYBIND11_TOSTRING(x) PYBIND11_STRINGIFY(x)
345#define PYBIND11_CONCAT(first, second) first##second
346#define PYBIND11_ENSURE_INTERNALS_READY pybind11::detail::get_internals();
348#define PYBIND11_CHECK_PYTHON_VERSION \
350 const char *compiled_ver \
351 = PYBIND11_TOSTRING(PY_MAJOR_VERSION) "." PYBIND11_TOSTRING(PY_MINOR_VERSION); \
352 const char *runtime_ver = Py_GetVersion(); \
353 size_t len = std::strlen(compiled_ver); \
354 if (std::strncmp(runtime_ver, compiled_ver, len) != 0 \
355 || (runtime_ver[len] >= '0' && runtime_ver[len] <= '9')) { \
356 PyErr_Format(PyExc_ImportError, \
357 "Python version mismatch: module was compiled for Python %s, " \
358 "but the interpreter version is incompatible: %s.", \
365#if PY_VERSION_HEX >= 0x03030000
367# define PYBIND11_CATCH_INIT_EXCEPTIONS \
368 catch (pybind11::error_already_set & e) { \
369 pybind11::raise_from(e, PyExc_ImportError, "initialization failed"); \
372 catch (const std::exception &e) { \
373 PyErr_SetString(PyExc_ImportError, e.what()); \
379# define PYBIND11_CATCH_INIT_EXCEPTIONS \
380 catch (pybind11::error_already_set & e) { \
381 PyErr_SetString(PyExc_ImportError, e.what()); \
384 catch (const std::exception &e) { \
385 PyErr_SetString(PyExc_ImportError, e.what()); \
406#define PYBIND11_PLUGIN(name) \
407 PYBIND11_DEPRECATED("PYBIND11_PLUGIN is deprecated, use PYBIND11_MODULE") \
408 static PyObject *pybind11_init(); \
409 PYBIND11_PLUGIN_IMPL(name) { \
410 PYBIND11_CHECK_PYTHON_VERSION \
411 PYBIND11_ENSURE_INTERNALS_READY \
413 return pybind11_init(); \
415 PYBIND11_CATCH_INIT_EXCEPTIONS \
417 PyObject *pybind11_init()
440#define PYBIND11_MODULE(name, variable) \
441 static ::pybind11::module_::module_def PYBIND11_CONCAT(pybind11_module_def_, name) \
442 PYBIND11_MAYBE_UNUSED; \
443 PYBIND11_MAYBE_UNUSED \
444 static void PYBIND11_CONCAT(pybind11_init_, name)(::pybind11::module_ &); \
445 PYBIND11_PLUGIN_IMPL(name) { \
446 PYBIND11_CHECK_PYTHON_VERSION \
447 PYBIND11_ENSURE_INTERNALS_READY \
448 auto m = ::pybind11::module_::create_extension_module( \
449 PYBIND11_TOSTRING(name), nullptr, &PYBIND11_CONCAT(pybind11_module_def_, name)); \
451 PYBIND11_CONCAT(pybind11_init_, name)(m); \
454 PYBIND11_CATCH_INIT_EXCEPTIONS \
456 void PYBIND11_CONCAT(pybind11_init_, name)(::pybind11::module_ & (variable))
461using
size_t =
std::
size_t;
463template <typename IntType>
465 static_assert(
sizeof(IntType) <=
sizeof(
ssize_t),
"Implicit narrowing is not permitted.");
466 return static_cast<ssize_t>(val);
523inline static constexpr
int log2(
size_t n,
int k = 0) {
524 return (n <= 1) ? k :
log2(n >> 1, k + 1);
529 return 1 + ((s - 1) >>
log2(
sizeof(
void *)));
539 static_assert(
sizeof(std::shared_ptr<int>) >=
sizeof(std::unique_ptr<int>),
540 "pybind assumes std::shared_ptrs are at least as big as std::unique_ptrs");
607 bool throw_if_missing =
true);
614static_assert(std::is_standard_layout<instance>::value,
615 "Internal error: `pybind11::detail::instance` is not standard layout!");
618#if defined(PYBIND11_CPP14) && (!defined(_MSC_VER) || _MSC_VER >= 1910)
619using std::conditional_t;
620using std::enable_if_t;
621using std::remove_cv_t;
622using std::remove_reference_t;
624template <
bool B,
typename T =
void>
626template <
bool B,
typename T,
typename F>
634#if defined(PYBIND11_CPP20)
635using std::remove_cvref;
636using std::remove_cvref_t;
647#if defined(PYBIND11_CPP14)
648using std::index_sequence;
649using std::make_index_sequence;
653template <
size_t N,
size_t... S>
655template <
size_t... S>
664template <
typename ISeq,
size_t,
bool...>
668template <
size_t... IPrev,
size_t I,
bool B,
bool... Bs>
670 :
select_indices_impl<conditional_t<B, index_sequence<IPrev..., I>, index_sequence<IPrev...>>,
685#if defined(__PGIC__) || defined(__INTEL_COMPILER)
686template <
typename...>
689template <
typename...>
693template <
typename... Ts>
698#if defined(__cpp_fold_expressions) && !(defined(_MSC_VER) && (_MSC_VER < 1916))
699template <
class... Ts>
701template <
class... Ts>
703#elif !defined(_MSC_VER)
706template <
class... Ts>
708template <
class... Ts>
713template <
class... Ts>
714using all_of = std::conjunction<Ts...>;
715template <
class... Ts>
716using any_of = std::disjunction<Ts...>;
718template <
class... Ts>
721template <
class T,
template <
class>
class... Predicates>
723template <
class T,
template <
class>
class... Predicates>
725template <
class T,
template <
class>
class... Predicates>
731template <
typename C,
typename R,
typename...
A>
735template <
typename C,
typename R,
typename...
A>
761template <
typename T,
size_t N>
765template <
typename T,
size_t N>
776template <
typename...>
780#ifdef __cpp_fold_expressions
781template <
typename... Ts>
783 return (0 + ... +
size_t{ns});
787template <
typename T,
typename... Ts>
795constexpr
int first(
int i) {
return i; }
796template <
typename T,
typename... Ts>
797constexpr int first(
int i, T v, Ts... vs) {
798 return v ? i :
first(i + 1, vs...);
801constexpr int last(
int ,
int result) {
return result; }
802template <
typename T,
typename... Ts>
803constexpr int last(
int i,
int result, T v, Ts... vs) {
804 return last(i + 1, v ? i : result, vs...);
810template <
template <
typename>
class Predicate,
typename... Ts>
812 return constexpr_impl::first(0, Predicate<Ts>::value...);
816template <
template <
typename>
class Predicate,
typename... Ts>
818 return constexpr_impl::last(0, -1, Predicate<Ts>::value...);
822template <
size_t N,
typename T,
typename... Ts>
826template <
typename T,
typename... Ts>
833template <
template <
typename>
class Predicate,
typename Default,
typename... Ts>
836 static_assert(
found <= 1,
"Found more than one type matching the predicate");
841template <
template <
typename>
class P,
typename Default>
846template <
template <
typename>
class Predicate,
typename Default,
typename... Ts>
850template <
typename T,
typename... >
854template <
typename T,
typename... Us>
859template <
typename Base,
typename Derived>
866template <
typename Base,
typename Derived>
868 =
bool_constant<(std::is_same<Base, Derived>::value || std::is_base_of<Base, Derived>::value)
869 && std::is_convertible<Derived *, Base *>::value>;
871template <
template <
typename...>
class Base>
873 template <
typename... Us>
880template <
template <
typename...>
class Base,
typename T>
881#if !defined(_MSC_VER)
886 : decltype(is_template_base_of_impl<Base>::check((intrinsic_t<T> *) nullptr)) {
892template <
template <
typename...>
class Class,
typename T>
894template <
template <
typename...>
class Class,
typename... Us>
902template <
typename T,
typename =
void>
906 void_t<decltype(*std::declval<T &>()),
decltype(++std::declval<T &>())>>
912 && std::is_function<typename std::remove_pointer<T>::type>::value>;
924template <
typename Function,
typename F = remove_reference_t<Function>>
926 std::is_function<F>::value,
929 std::remove_pointer<F>,
939 std::is_member_pointer>;
943#if defined(__cpp_fold_expressions) && !defined(__INTEL_COMPILER)
945# define PYBIND11_EXPAND_SIDE_EFFECTS(PATTERN) (((PATTERN), void()), ...)
948# define PYBIND11_EXPAND_SIDE_EFFECTS(PATTERN) \
949 (void) pybind11::detail::expand_side_effects { ((PATTERN), void(), false)..., false }
955# pragma warning(push)
956# pragma warning(disable : 4275)
963 using std::runtime_error::runtime_error;
971#define PYBIND11_RUNTIME_EXCEPTION(name, type) \
972 class PYBIND11_EXPORT_EXCEPTION name : public builtin_exception { \
974 using builtin_exception::builtin_exception; \
975 name() : name("") {} \
976 void set_error() const override { PyErr_SetString(type, what()); } \
993 throw std::runtime_error(reason);
996 throw std::runtime_error(reason);
999template <
typename T,
typename SFINAE =
void>
1008template <
typename T,
typename SFINAE =
void>
1012template <
typename T>
1015 static constexpr int index
1016 = std::is_same<T, bool>::value
1019 + (std::is_integral<T>::value
1020 ? detail::log2(
sizeof(T)) * 2 + std::is_unsigned<T>::value
1022 + (std::is_same<T, double>::value ? 1
1023 : std::is_same<T, long double>::value ? 2
1028template <
typename T>
1030 static constexpr const char c =
"?bBhHiIqQfdg"[detail::is_fmt_numeric<T>::index];
1031 static constexpr const char value[2] = {c,
'\0'};
1032 static std::string
format() {
return std::string(1, c); }
1035#if !defined(PYBIND11_CPP17)
1037template <
typename T>
1052 template <
typename T>
1057template <
typename... Args>
1062 template <
typename Return>
1063 constexpr auto operator()(Return (*pf)(Args...)) const noexcept -> decltype(pf) {
1067 template <
typename Return,
typename Class>
1068 constexpr auto operator()(Return (Class::*pmf)(Args...), std::false_type = {}) const noexcept
1073 template <
typename Return,
typename Class>
1074 constexpr auto operator()(Return (Class::*pmf)(Args...)
const, std::true_type)
const noexcept
1082#if defined(PYBIND11_CPP14)
1083# define PYBIND11_OVERLOAD_CAST 1
1087template <
typename... Args>
1088static constexpr detail::overload_cast_impl<Args...>
overload_cast = {};
1095static constexpr auto const_ = std::true_type{};
1097#if !defined(PYBIND11_CPP14)
1098template <
typename... Args>
1100 static_assert(detail::deferred_t<std::false_type, Args...>::value,
1101 "pybind11::overload_cast<...> requires compiling in C++14 mode");
1110template <
typename T>
1118 template <typename It, typename = enable_if_t<is_input_iterator<It>::value>>
1123 template <
typename Container,
1125 std::is_convertible<decltype(*std::begin(std::declval<const Container &>())),
1132 template <typename TIn, typename = enable_if_t<std::is_convertible<TIn, T>::value>>
1141 operator std::vector<T> &&() && {
return std::move(
v); }
1155template <
typename T>
1156inline static std::shared_ptr<T>
1162#if defined(__cpp_lib_enable_shared_from_this) && (!defined(_MSC_VER) || _MSC_VER >= 1912)
1163 return holder_value_ptr->weak_from_this().lock();
1166 return holder_value_ptr->shared_from_this();
1167 }
catch (
const std::bad_weak_ptr &) {
1174template <
typename... Args>
1175#if defined(_MSC_VER) && _MSC_VER >= 1910 && _MSC_VER < 1920
1183#if defined(_MSC_VER) && _MSC_VER <= 1916
1184# define PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(...) \
1185 detail::silence_unused_warnings(__VA_ARGS__)
1187# define PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(...)
1191#if defined(__GNUG__) && !defined(__clang__) && !defined(__INTEL_COMPILER)
1192# define PYBIND11_WORKAROUND_INCORRECT_GCC_UNUSED_BUT_SET_PARAMETER(...) \
1193 detail::silence_unused_warnings(__VA_ARGS__)
1195# define PYBIND11_WORKAROUND_INCORRECT_GCC_UNUSED_BUT_SET_PARAMETER(...)
1198#if defined(_MSC_VER)
1201constexpr inline bool silence_msvc_c4127(
bool cond) {
return cond; }
1203# define PYBIND11_SILENCE_MSVC_C4127(...) ::pybind11::detail::silence_msvc_c4127(__VA_ARGS__)
1206# define PYBIND11_SILENCE_MSVC_C4127(...) __VA_ARGS__
any_container(It first, It last)
std::vector< T > * operator->()
any_container(const Container &c)
std::vector< T > & operator*()
any_container(std::vector< T > &&v)
any_container(const std::initializer_list< TIn > &c)
const std::vector< T > & operator*() const
const std::vector< T > * operator->() const
C++ bindings of builtin Python exceptions.
virtual void set_error() const =0
Set the error using the Python C API.
typename std::enable_if< B, T >::type enable_if_t
from cpp_future import (convenient aliases from C++14/17)
std::string get_fully_qualified_tp_name(PyTypeObject *)
typename deferred_type< T, Us... >::type deferred_t
std::integral_constant< bool, B > bool_constant
Backports of std::bool_constant and std::negation to accommodate older compilers.
constexpr int last(int, int result)
static constexpr size_t size_in_ptrs(size_t s)
PYBIND11_NOINLINE void pybind11_fail(const char *reason)
Thrown when pybind11::cast or.
#define PYBIND11_NOINLINE
constexpr size_t instance_simple_holder_in_ptrs()
The space to allocate for simple layout instance holders (see below) in multiple of the size of a poi...
void silence_unused_warnings(Args &&...)
typename std::remove_reference< T >::type remove_reference_t
constexpr int constexpr_first()
Return the index of the first type in Ts which satisfies Predicate<T>.
typename remove_cvref< T >::type remove_cvref_t
static std::shared_ptr< T > try_get_shared_from_this(std::enable_shared_from_this< T > *holder_value_ptr)
typename intrinsic_type< T >::type intrinsic_t
bool_constant< std::is_pointer< T >::value &&std::is_function< typename std::remove_pointer< T >::type >::value > is_function_pointer
all_of< Predicates< T >... > satisfies_all_of
#define PYBIND11_EXPORT_EXCEPTION
decltype(is_template_base_of_impl< Base >::check((intrinsic_t< T > *) nullptr)) is_template_base_of
Check if a template is the base of a type.
constexpr int first(int i)
Implementation details for constexpr functions.
static constexpr auto const_
Const member function selector for overload_cast.
static constexpr int log2(size_t n, int k=0)
constexpr size_t constexpr_sum()
Compile-time integer sum.
#define PYBIND11_RUNTIME_EXCEPTION(name, type)
typename std::remove_cv< T >::type remove_cv_t
bool_constant<(std::is_same< Base, Derived >::value||std::is_base_of< Base, Derived >::value) &&std::is_convertible< Derived *, Base * >::value > is_accessible_base_of
Like is_base_of, but also requires that the base type is accessible (i.e.
#define PYBIND11_NAMESPACE_END(name)
typename exactly_one< Predicate, Default, Ts... >::type exactly_one_t
conditional_t< std::is_function< F >::value, F, typename conditional_t< std::is_pointer< F >::value||std::is_member_pointer< F >::value, std::remove_pointer< F >, strip_function_object< F > >::type > function_signature_t
#define PYBIND11_NAMESPACE_BEGIN(name)
typename make_index_sequence_impl< N >::type make_index_sequence
bool_constant< std::is_base_of< Base, Derived >::value &&!std::is_same< Base, Derived >::value > is_strict_base_of
Like is_base_of, but requires a strict base (i.e.
typename void_t_impl< Ts... >::type void_t
std::is_same< bools< Ts::value..., true >, bools< true, Ts::value... > > all_of
typename std::conditional< B, T, F >::type conditional_t
constexpr int constexpr_last()
Return the index of the last type in Ts which satisfies Predicate<T>, or -1 if none match.
return_value_policy
Approach used to cast a previously unknown C++ instance into a Python object.
@ copy
Create a new copy of the returned object, which will be owned by Python.
@ automatic_reference
As above, but use policy return_value_policy::reference when the return value is a pointer.
@ automatic
This is the default return value policy, which falls back to the policy return_value_policy::take_own...
@ move
Use std::move to move the return value contents into a new instance that will be owned by Python.
@ take_ownership
Reference an existing object (i.e.
@ reference_internal
This policy only applies to methods and properties.
@ reference
Reference an existing object, but do not take ownership.
ssize_t ssize_t_cast(const IntType &val)
bool[] expand_side_effects
Apply a function over each element of a parameter pack.
typename select_indices_impl< index_sequence<>, 0, Bs... >::type select_indices
typename std::enable_if< B, T >::type enable_if_t
from cpp_future import (convenient aliases from C++14/17)
std::integral_constant< bool, B > bool_constant
Backports of std::bool_constant and std::negation to accommodate older compilers.
constexpr int last(int, int result)
constexpr size_t instance_simple_holder_in_ptrs()
The space to allocate for simple layout instance holders (see below) in multiple of the size of a poi...
constexpr int constexpr_first()
Return the index of the first type in Ts which satisfies Predicate<T>.
constexpr int first(int i)
Implementation details for constexpr functions.
constexpr size_t constexpr_sum()
Compile-time integer sum.
typename std::remove_cv< T >::type remove_cv_t
typename void_t_impl< Ts... >::type void_t
typename std::conditional< B, T, F >::type conditional_t
@ move
Use std::move to move the return value contents into a new instance that will be owned by Python.
Compile-time all/any/none of that check the boolean value of all template types.
Defer the evaluation of type T until types Us are instantiated.
RAII wrapper that temporarily clears any Python error state.
Return the one and only type which matches the predicate, or Default if none match.
static constexpr auto index
static constexpr auto found
conditional_t< found, typename pack_element< index, Ts... >::type, Default > type
The 'instance' type which needs to be standard layout (need to be able to use 'offsetof')
nonsimple_values_and_holders nonsimple
void deallocate_layout()
Destroys/deallocates all of the above.
bool simple_layout
An instance has two possible value/holder layouts.
bool has_patients
If true, get_internals().patients has an entry for this object.
value_and_holder get_value_and_holder(const type_info *find_type=nullptr, bool throw_if_missing=true)
Returns the value_and_holder wrapper for the given type (or the first, if find_type omitted).
PyObject * weakrefs
Weak references.
void * simple_value_holder[1+instance_simple_holder_in_ptrs()]
bool simple_instance_registered
For simple layout, tracks whether the instance is registered in registered_instances
bool owned
If true, the pointer is owned which means we're free to manage it with a holder.
static constexpr uint8_t status_instance_registered
bool simple_holder_constructed
For simple layout, tracks whether the holder has been constructed.
static constexpr uint8_t status_holder_constructed
Bit values for the non-simple status flags.
void allocate_layout()
Initializes all of the above type/values/holders data (but not the instance values themselves)
Helper template to strip away type modifiers.
static constexpr bool value
Check if T is an instantiation of the template Class.
static std::false_type check(...)
static std::true_type check(Base< Us... > *)
Dummy destructor wrapper that can be used to expose classes with a private destructor.
void ** values_and_holders
constexpr auto operator()(Return(*pf)(Args...)) const noexcept -> decltype(pf)
constexpr auto operator()(Return(Class::*pmf)(Args...), std::false_type={}) const noexcept -> decltype(pmf)
constexpr auto operator()(Return(Class::*pmf)(Args...) const, std::true_type) const noexcept -> decltype(pmf)
constexpr overload_cast_impl()
Return the Nth element from the parameter pack.
typename pack_element< N - 1, Ts... >::type type
Strip the class from a method type.
remove_cv_t< remove_reference_t< T > > type
Make an index sequence of the indices of true arguments.
Additional type information which does not fit into the PyTypeObject.
Helper template which holds a list of types.
Helper type to replace 'void' in some expressions.