12#define PYBIND11_VERSION_MAJOR 2
13#define PYBIND11_VERSION_MINOR 10
14#define PYBIND11_VERSION_PATCH 4
18#define PYBIND11_VERSION_HEX 0x020A0400
31# define PYBIND11_COMPILER_MSVC
32# define PYBIND11_PRAGMA(...) __pragma(__VA_ARGS__)
33# define PYBIND11_WARNING_PUSH PYBIND11_PRAGMA(warning(push))
34# define PYBIND11_WARNING_POP PYBIND11_PRAGMA(warning(pop))
35#elif defined(__INTEL_COMPILER)
36# define PYBIND11_COMPILER_INTEL
37# define PYBIND11_PRAGMA(...) _Pragma(#__VA_ARGS__)
38# define PYBIND11_WARNING_PUSH PYBIND11_PRAGMA(warning push)
39# define PYBIND11_WARNING_POP PYBIND11_PRAGMA(warning pop)
40#elif defined(__clang__)
41# define PYBIND11_COMPILER_CLANG
42# define PYBIND11_PRAGMA(...) _Pragma(#__VA_ARGS__)
43# define PYBIND11_WARNING_PUSH PYBIND11_PRAGMA(clang diagnostic push)
44# define PYBIND11_WARNING_POP PYBIND11_PRAGMA(clang diagnostic push)
45#elif defined(__GNUC__)
46# define PYBIND11_COMPILER_GCC
47# define PYBIND11_PRAGMA(...) _Pragma(#__VA_ARGS__)
48# define PYBIND11_WARNING_PUSH PYBIND11_PRAGMA(GCC diagnostic push)
49# define PYBIND11_WARNING_POP PYBIND11_PRAGMA(GCC diagnostic pop)
52#ifdef PYBIND11_COMPILER_MSVC
53# define PYBIND11_WARNING_DISABLE_MSVC(name) PYBIND11_PRAGMA(warning(disable : name))
55# define PYBIND11_WARNING_DISABLE_MSVC(name)
58#ifdef PYBIND11_COMPILER_CLANG
59# define PYBIND11_WARNING_DISABLE_CLANG(name) PYBIND11_PRAGMA(clang diagnostic ignored name)
61# define PYBIND11_WARNING_DISABLE_CLANG(name)
64#ifdef PYBIND11_COMPILER_GCC
65# define PYBIND11_WARNING_DISABLE_GCC(name) PYBIND11_PRAGMA(GCC diagnostic ignored name)
67# define PYBIND11_WARNING_DISABLE_GCC(name)
70#ifdef PYBIND11_COMPILER_INTEL
71# define PYBIND11_WARNING_DISABLE_INTEL(name) PYBIND11_PRAGMA(warning disable name)
73# define PYBIND11_WARNING_DISABLE_INTEL(name)
76#define PYBIND11_NAMESPACE_BEGIN(name) \
80#define PYBIND11_NAMESPACE_END(name) \
81 PYBIND11_WARNING_POP \
87#if !defined(PYBIND11_NAMESPACE)
89# define PYBIND11_NAMESPACE pybind11 __attribute__((visibility("hidden")))
91# define PYBIND11_NAMESPACE pybind11
95#if !(defined(_MSC_VER) && __cplusplus == 199711L)
96# if __cplusplus >= 201402L
97# define PYBIND11_CPP14
98# if __cplusplus >= 201703L
99# define PYBIND11_CPP17
100# if __cplusplus >= 202002L
101# define PYBIND11_CPP20
106#elif defined(_MSC_VER) && __cplusplus == 199711L
110# if _MSVC_LANG >= 201402L
111# define PYBIND11_CPP14
112# if _MSVC_LANG > 201402L
113# define PYBIND11_CPP17
114# if _MSVC_LANG >= 202002L
115# define PYBIND11_CPP20
122#if defined(__INTEL_COMPILER)
123# if __INTEL_COMPILER < 1800
124# error pybind11 requires Intel C++ compiler v18 or newer
125# elif __INTEL_COMPILER < 1900 && defined(PYBIND11_CPP14)
126# error pybind11 supports only C++11 with Intel C++ compiler v18. Use v19 or newer for C++14.
130# pragma warning disable 2196
131#elif defined(__clang__) && !defined(__apple_build_version__)
132# if __clang_major__ < 3 || (__clang_major__ == 3 && __clang_minor__ < 3)
133# error pybind11 requires clang 3.3 or newer
135#elif defined(__clang__)
138# if __clang_major__ < 5
139# error pybind11 requires Xcode/clang 5.0 or newer
141#elif defined(__GNUG__)
142# if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 8)
143# error pybind11 requires gcc 4.8 or newer
145#elif defined(_MSC_VER)
147# error pybind11 2.10+ requires MSVC 2017 or newer
151#if !defined(PYBIND11_EXPORT)
152# if defined(WIN32) || defined(_WIN32)
153# define PYBIND11_EXPORT __declspec(dllexport)
155# define PYBIND11_EXPORT __attribute__((visibility("default")))
159#if !defined(PYBIND11_EXPORT_EXCEPTION)
160# if defined(__apple_build_version__)
161# define PYBIND11_EXPORT_EXCEPTION PYBIND11_EXPORT
163# define PYBIND11_EXPORT_EXCEPTION
173#if !defined(PYBIND11_NOINLINE_FORCED) \
174 && (defined(__CUDACC__) || (defined(__GNUC__) && (__GNUC__ == 7 || __GNUC__ == 8)))
175# define PYBIND11_NOINLINE_DISABLED
181#if defined(PYBIND11_NOINLINE_DISABLED)
182# define PYBIND11_NOINLINE inline
183#elif defined(_MSC_VER)
184# define PYBIND11_NOINLINE __declspec(noinline) inline
186# define PYBIND11_NOINLINE __attribute__((noinline)) inline
189#if defined(__MINGW32__)
192# define PYBIND11_DEPRECATED(reason)
193#elif defined(PYBIND11_CPP14)
194# define PYBIND11_DEPRECATED(reason) [[deprecated(reason)]]
196# define PYBIND11_DEPRECATED(reason) __attribute__((deprecated(reason)))
199#if defined(PYBIND11_CPP17)
200# define PYBIND11_MAYBE_UNUSED [[maybe_unused]]
201#elif defined(_MSC_VER) && !defined(__clang__)
202# define PYBIND11_MAYBE_UNUSED
204# define PYBIND11_MAYBE_UNUSED __attribute__((__unused__))
210# define HAVE_SNPRINTF 1
218# if defined(_DEBUG) && !defined(Py_DEBUG)
224# if _MSVC_STL_VERSION >= 143
227# define PYBIND11_DEBUG_MARKER
233#if defined(__STDC_LIB_EXT1__) && !defined(__STDC_WANT_LIB_EXT1__)
234# define __STDC_WANT_LIB_EXT1__
239# if defined(PYBIND11_CPP17) && __has_include(<optional>)
240# define PYBIND11_HAS_OPTIONAL 1
243# if defined(PYBIND11_CPP14) && (__has_include(<experimental/optional>) && \
244 !__has_include(<optional>))
245# define PYBIND11_HAS_EXP_OPTIONAL 1
248# if defined(PYBIND11_CPP17) && __has_include(<variant>)
249# define PYBIND11_HAS_VARIANT 1
251#elif defined(_MSC_VER) && defined(PYBIND11_CPP17)
252# define PYBIND11_HAS_OPTIONAL 1
253# define PYBIND11_HAS_VARIANT 1
256#if defined(PYBIND11_CPP17)
257# if defined(__has_include)
258# if __has_include(<string_view>)
259# define PYBIND11_HAS_STRING_VIEW
261# elif defined(_MSC_VER)
262# define PYBIND11_HAS_STRING_VIEW
268#if PY_VERSION_HEX < 0x03060000
269# error "PYTHON < 3.6 IS UNSUPPORTED. pybind11 v2.9 was the last to support Python 2 and 3.5."
271#include <frameobject.h>
291#if defined(PYPY_VERSION) && !defined(PYBIND11_SIMPLE_GIL_MANAGEMENT)
292# define PYBIND11_SIMPLE_GIL_MANAGEMENT
296# if defined(PYBIND11_DEBUG_MARKER)
298# undef PYBIND11_DEBUG_MARKER
306#include <forward_list>
310#include <type_traits>
312#include <unordered_map>
313#include <unordered_set>
315#if defined(__has_include)
316# if __has_include(<version>)
322#if defined(__cpp_lib_char8_t) && __cpp_lib_char8_t >= 201811L
323# define PYBIND11_HAS_U8STRING
327#if !defined(NDEBUG) && !defined(PY_ASSERT_GIL_HELD_INCREF_DECREF) \
328 && !(defined(PYPY_VERSION) \
329 && defined(_MSC_VER))
331 && !defined(PYBIND11_ASSERT_GIL_HELD_INCREF_DECREF)
350#define PYBIND11_INSTANCE_METHOD_NEW(ptr, class_) PyInstanceMethod_New(ptr)
351#define PYBIND11_INSTANCE_METHOD_CHECK PyInstanceMethod_Check
352#define PYBIND11_INSTANCE_METHOD_GET_FUNCTION PyInstanceMethod_GET_FUNCTION
353#define PYBIND11_BYTES_CHECK PyBytes_Check
354#define PYBIND11_BYTES_FROM_STRING PyBytes_FromString
355#define PYBIND11_BYTES_FROM_STRING_AND_SIZE PyBytes_FromStringAndSize
356#define PYBIND11_BYTES_AS_STRING_AND_SIZE PyBytes_AsStringAndSize
357#define PYBIND11_BYTES_AS_STRING PyBytes_AsString
358#define PYBIND11_BYTES_SIZE PyBytes_Size
359#define PYBIND11_LONG_CHECK(o) PyLong_Check(o)
360#define PYBIND11_LONG_AS_LONGLONG(o) PyLong_AsLongLong(o)
361#define PYBIND11_LONG_FROM_SIGNED(o) PyLong_FromSsize_t((ssize_t) (o))
362#define PYBIND11_LONG_FROM_UNSIGNED(o) PyLong_FromSize_t((size_t) (o))
363#define PYBIND11_BYTES_NAME "bytes"
364#define PYBIND11_STRING_NAME "str"
365#define PYBIND11_SLICE_OBJECT PyObject
366#define PYBIND11_FROM_STRING PyUnicode_FromString
367#define PYBIND11_STR_TYPE ::pybind11::str
368#define PYBIND11_BOOL_ATTR "__bool__"
369#define PYBIND11_NB_BOOL(ptr) ((ptr)->nb_bool)
370#define PYBIND11_BUILTINS_MODULE "builtins"
373#define PYBIND11_PLUGIN_IMPL(name) \
374 extern "C" PYBIND11_MAYBE_UNUSED PYBIND11_EXPORT PyObject *PyInit_##name(); \
375 extern "C" PYBIND11_EXPORT PyObject *PyInit_##name()
377#define PYBIND11_TRY_NEXT_OVERLOAD ((PyObject *) 1)
378#define PYBIND11_STRINGIFY(x) #x
379#define PYBIND11_TOSTRING(x) PYBIND11_STRINGIFY(x)
380#define PYBIND11_CONCAT(first, second) first##second
381#define PYBIND11_ENSURE_INTERNALS_READY pybind11::detail::get_internals();
383#define PYBIND11_CHECK_PYTHON_VERSION \
385 const char *compiled_ver \
386 = PYBIND11_TOSTRING(PY_MAJOR_VERSION) "." PYBIND11_TOSTRING(PY_MINOR_VERSION); \
387 const char *runtime_ver = Py_GetVersion(); \
388 size_t len = std::strlen(compiled_ver); \
389 if (std::strncmp(runtime_ver, compiled_ver, len) != 0 \
390 || (runtime_ver[len] >= '0' && runtime_ver[len] <= '9')) { \
391 PyErr_Format(PyExc_ImportError, \
392 "Python version mismatch: module was compiled for Python %s, " \
393 "but the interpreter version is incompatible: %s.", \
400#define PYBIND11_CATCH_INIT_EXCEPTIONS \
401 catch (pybind11::error_already_set & e) { \
402 pybind11::raise_from(e, PyExc_ImportError, "initialization failed"); \
405 catch (const std::exception &e) { \
406 PyErr_SetString(PyExc_ImportError, e.what()); \
425#define PYBIND11_PLUGIN(name) \
426 PYBIND11_DEPRECATED("PYBIND11_PLUGIN is deprecated, use PYBIND11_MODULE") \
427 static PyObject *pybind11_init(); \
428 PYBIND11_PLUGIN_IMPL(name) { \
429 PYBIND11_CHECK_PYTHON_VERSION \
430 PYBIND11_ENSURE_INTERNALS_READY \
432 return pybind11_init(); \
434 PYBIND11_CATCH_INIT_EXCEPTIONS \
436 PyObject *pybind11_init()
459#define PYBIND11_MODULE(name, variable) \
460 static ::pybind11::module_::module_def PYBIND11_CONCAT(pybind11_module_def_, name) \
461 PYBIND11_MAYBE_UNUSED; \
462 PYBIND11_MAYBE_UNUSED \
463 static void PYBIND11_CONCAT(pybind11_init_, name)(::pybind11::module_ &); \
464 PYBIND11_PLUGIN_IMPL(name) { \
465 PYBIND11_CHECK_PYTHON_VERSION \
466 PYBIND11_ENSURE_INTERNALS_READY \
467 auto m = ::pybind11::module_::create_extension_module( \
468 PYBIND11_TOSTRING(name), nullptr, &PYBIND11_CONCAT(pybind11_module_def_, name)); \
470 PYBIND11_CONCAT(pybind11_init_, name)(m); \
473 PYBIND11_CATCH_INIT_EXCEPTIONS \
475 void PYBIND11_CONCAT(pybind11_init_, name)(::pybind11::module_ & (variable))
480using
size_t =
std::
size_t;
482template <typename IntType>
484 static_assert(
sizeof(IntType) <=
sizeof(
ssize_t),
"Implicit narrowing is not permitted.");
485 return static_cast<ssize_t>(val);
542inline static constexpr
int log2(
size_t n,
int k = 0) {
543 return (n <= 1) ? k :
log2(n >> 1, k + 1);
548 return 1 + ((s - 1) >>
log2(
sizeof(
void *)));
558 static_assert(
sizeof(std::shared_ptr<int>) >=
sizeof(std::unique_ptr<int>),
559 "pybind assumes std::shared_ptrs are at least as big as std::unique_ptrs");
626 bool throw_if_missing =
true);
633static_assert(std::is_standard_layout<instance>::value,
634 "Internal error: `pybind11::detail::instance` is not standard layout!");
637#if defined(PYBIND11_CPP14)
638using std::conditional_t;
639using std::enable_if_t;
640using std::remove_cv_t;
641using std::remove_reference_t;
643template <
bool B,
typename T =
void>
645template <
bool B,
typename T,
typename F>
653#if defined(PYBIND11_CPP20)
654using std::remove_cvref;
655using std::remove_cvref_t;
666#if defined(PYBIND11_CPP14)
667using std::index_sequence;
668using std::make_index_sequence;
672template <
size_t N,
size_t...
S>
674template <
size_t...
S>
683template <
typename ISeq,
size_t,
bool...>
687template <
size_t... IPrev,
size_t I,
bool B,
bool... Bs>
689 :
select_indices_impl<conditional_t<B, index_sequence<IPrev..., I>, index_sequence<IPrev...>>,
704#if defined(__PGIC__) || defined(__INTEL_COMPILER)
705template <
typename...>
708template <
typename...>
712template <
typename... Ts>
717#if defined(__cpp_fold_expressions) && !(defined(_MSC_VER) && (_MSC_VER < 1916))
718template <
class... Ts>
720template <
class... Ts>
722#elif !defined(_MSC_VER)
725template <
class... Ts>
727template <
class... Ts>
732template <
class... Ts>
733using all_of = std::conjunction<Ts...>;
734template <
class... Ts>
735using any_of = std::disjunction<Ts...>;
737template <
class... Ts>
740template <
class T,
template <
class>
class... Predicates>
742template <
class T,
template <
class>
class... Predicates>
744template <
class T,
template <
class>
class... Predicates>
750template <
typename C,
typename R,
typename...
A>
754template <
typename C,
typename R,
typename...
A>
780template <
typename T,
size_t N>
784template <
typename T,
size_t N>
795template <
typename...>
799#ifdef __cpp_fold_expressions
800template <
typename... Ts>
802 return (0 + ... +
size_t{ns});
806template <
typename T,
typename... Ts>
814constexpr
int first(
int i) {
return i; }
815template <
typename T,
typename... Ts>
816constexpr int first(
int i, T v, Ts... vs) {
817 return v ? i :
first(i + 1, vs...);
820constexpr int last(
int ,
int result) {
return result; }
821template <
typename T,
typename... Ts>
822constexpr int last(
int i,
int result, T v, Ts... vs) {
823 return last(i + 1, v ? i : result, vs...);
829template <
template <
typename>
class Predicate,
typename... Ts>
831 return constexpr_impl::first(0, Predicate<Ts>::value...);
835template <
template <
typename>
class Predicate,
typename... Ts>
837 return constexpr_impl::last(0, -1, Predicate<Ts>::value...);
841template <
size_t N,
typename T,
typename... Ts>
845template <
typename T,
typename... Ts>
852template <
template <
typename>
class Predicate,
typename Default,
typename... Ts>
855 static_assert(
found <= 1,
"Found more than one type matching the predicate");
860template <
template <
typename>
class P,
typename Default>
865template <
template <
typename>
class Predicate,
typename Default,
typename... Ts>
869template <
typename T,
typename... >
873template <
typename T,
typename... Us>
878template <
typename Base,
typename Derived>
885template <
typename Base,
typename Derived>
887 =
bool_constant<(std::is_same<Base, Derived>::value || std::is_base_of<Base, Derived>::value)
888 && std::is_convertible<Derived *, Base *>::value>;
890template <
template <
typename...>
class Base>
892 template <
typename... Us>
899template <
template <
typename...>
class Base,
typename T>
902#if !defined(_MSC_VER)
907 : decltype(is_template_base_of_impl<Base>::check((intrinsic_t<T> *) nullptr)) {
913template <
template <
typename...>
class Class,
typename T>
915template <
template <
typename...>
class Class,
typename... Us>
923template <
typename T,
typename =
void>
927 void_t<decltype(*std::declval<T &>()),
decltype(++std::declval<T &>())>>
933 && std::is_function<typename std::remove_pointer<T>::type>::value>;
945template <
typename Function,
typename F = remove_reference_t<Function>>
947 std::is_function<F>::value,
950 std::remove_pointer<F>,
960 std::is_member_pointer>;
964#if defined(__cpp_fold_expressions) && !defined(__INTEL_COMPILER)
966# define PYBIND11_EXPAND_SIDE_EFFECTS(PATTERN) (((PATTERN), void()), ...)
969# define PYBIND11_EXPAND_SIDE_EFFECTS(PATTERN) \
970 (void) pybind11::detail::expand_side_effects { ((PATTERN), void(), false)..., false }
978 using std::runtime_error::runtime_error;
983#define PYBIND11_RUNTIME_EXCEPTION(name, type) \
984 class PYBIND11_EXPORT_EXCEPTION name : public builtin_exception { \
986 using builtin_exception::builtin_exception; \
987 name() : name("") {} \
988 void set_error() const override { PyErr_SetString(type, what()); } \
1005 assert(!PyErr_Occurred());
1006 throw std::runtime_error(reason);
1009 assert(!PyErr_Occurred());
1010 throw std::runtime_error(reason);
1013template <
typename T,
typename SFINAE =
void>
1022template <
typename T,
typename SFINAE =
void>
1024 static constexpr bool value =
false;
1026template <
typename T>
1028 static constexpr bool value =
true;
1029 static constexpr int index
1030 = std::is_same<T, bool>::value
1033 + (std::is_integral<T>::value
1034 ? detail::log2(
sizeof(T)) * 2 + std::is_unsigned<T>::value
1036 + (std::is_same<T, double>::value ? 1
1037 : std::is_same<T, long double>::value ? 2
1042template <
typename T>
1044 static constexpr const char c =
"?bBhHiIqQfdg"[detail::is_fmt_numeric<T>::index];
1045 static constexpr const char value[2] = {
c,
'\0'};
1046 static std::string
format() {
return std::string(1, c); }
1049#if !defined(PYBIND11_CPP17)
1051template <
typename T>
1068 template <
typename T>
1073template <
typename... Args>
1075 template <
typename Return>
1076 constexpr auto operator()(Return (*pf)(Args...)) const noexcept -> decltype(pf) {
1080 template <
typename Return,
typename Class>
1081 constexpr auto operator()(Return (Class::*pmf)(Args...), std::false_type = {}) const noexcept
1086 template <
typename Return,
typename Class>
1087 constexpr auto operator()(Return (Class::*pmf)(Args...)
const, std::true_type)
const noexcept
1095#if defined(PYBIND11_CPP14)
1096# define PYBIND11_OVERLOAD_CAST 1
1100template <
typename... Args>
1101static constexpr detail::overload_cast_impl<Args...>
overload_cast{};
1107static constexpr auto const_ = std::true_type{};
1109#if !defined(PYBIND11_CPP14)
1110template <
typename... Args>
1112 static_assert(detail::deferred_t<std::false_type, Args...>::value,
1113 "pybind11::overload_cast<...> requires compiling in C++14 mode");
1122template <
typename T>
1130 template <typename It, typename = enable_if_t<is_input_iterator<It>::value>>
1135 template <
typename Container,
1137 std::is_convertible<decltype(*std::begin(std::declval<const Container &>())),
1144 template <typename TIn, typename = enable_if_t<std::is_convertible<TIn, T>::value>>
1153 operator std::vector<T> &&() && {
return std::move(
v); }
1167template <
typename T>
1168inline static std::shared_ptr<T>
1174#if defined(__cpp_lib_enable_shared_from_this) && (!defined(_MSC_VER) || _MSC_VER >= 1912)
1175 return holder_value_ptr->weak_from_this().lock();
1178 return holder_value_ptr->shared_from_this();
1179 }
catch (
const std::bad_weak_ptr &) {
1186template <
typename... Args>
1187#if defined(_MSC_VER) && _MSC_VER < 1920
1195#if defined(_MSC_VER) && _MSC_VER <= 1916
1196# define PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(...) \
1197 detail::silence_unused_warnings(__VA_ARGS__)
1199# define PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(...)
1203#if defined(__GNUG__) && !defined(__clang__) && !defined(__INTEL_COMPILER)
1204# define PYBIND11_WORKAROUND_INCORRECT_GCC_UNUSED_BUT_SET_PARAMETER(...) \
1205 detail::silence_unused_warnings(__VA_ARGS__)
1207# define PYBIND11_WORKAROUND_INCORRECT_GCC_UNUSED_BUT_SET_PARAMETER(...)
1210#if defined(__clang__) \
1211 && (defined(__apple_build_version__)
1213 || (__clang_major__ >= 7 \
1214 && __clang_major__ <= 12) \
1216# define PYBIND11_DETECTED_CLANG_WITH_MISLEADING_CALL_STD_MOVE_EXPLICITLY_WARNING
1231#if !defined(PYBIND11_DETAILED_ERROR_MESSAGES) && !defined(NDEBUG)
1232# define PYBIND11_DETAILED_ERROR_MESSAGES
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.
PYBIND11_WARNING_PUSH PYBIND11_WARNING_POP
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
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.
#define PYBIND11_WARNING_DISABLE_MSVC(name)
constexpr size_t constexpr_sum()
Compile-time integer sum.
typename std::remove_cv< T >::type remove_cv_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.
error_scope & operator=(const error_scope &)=delete
error_scope(const error_scope &)=delete
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
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.
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.
void allocate_layout()
Initializes all of the above type/values/holders data (but not the instance values themselves)
static constexpr uint8_t status_holder_constructed
Bit values for the non-simple status flags.
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).
void deallocate_layout()
Destroys/deallocates all of the above.
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)
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.