μHAL (v2.8.17)
Part of the IPbus software repository
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
common.h
Go to the documentation of this file.
1/*
2 pybind11/detail/common.h -- Basic macros
3
4 Copyright (c) 2016 Wenzel Jakob <wenzel.jakob@epfl.ch>
5
6 All rights reserved. Use of this source code is governed by a
7 BSD-style license that can be found in the LICENSE file.
8*/
9
10#pragma once
11
12#define PYBIND11_VERSION_MAJOR 2
13#define PYBIND11_VERSION_MINOR 9
14#define PYBIND11_VERSION_PATCH 2
15
16// Similar to Python's convention: https://docs.python.org/3/c-api/apiabiversion.html
17// Additional convention: 0xD = dev
18#define PYBIND11_VERSION_HEX 0x02090200
19
20#define PYBIND11_NAMESPACE_BEGIN(name) namespace name {
21#define PYBIND11_NAMESPACE_END(name) }
22
23// Robust support for some features and loading modules compiled against different pybind versions
24// requires forcing hidden visibility on pybind code, so we enforce this by setting the attribute
25// on the main `pybind11` namespace.
26#if !defined(PYBIND11_NAMESPACE)
27# ifdef __GNUG__
28# define PYBIND11_NAMESPACE pybind11 __attribute__((visibility("hidden")))
29# else
30# define PYBIND11_NAMESPACE pybind11
31# endif
32#endif
33
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
41# endif
42# endif
43# endif
44#elif defined(_MSC_VER) && __cplusplus == 199711L
45// MSVC sets _MSVC_LANG rather than __cplusplus (supposedly until the standard is fully
46// implemented). Unless you use the /Zc:__cplusplus flag on Visual Studio 2017 15.7 Preview 3
47// or newer.
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
54# endif
55# endif
56# endif
57#endif
58
59// Compiler version assertions
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.
65# endif
66/* The following pragma cannot be pop'ed:
67 https://community.intel.com/t5/Intel-C-Compiler/Inline-and-no-inline-warning/td-p/1216764 */
68# pragma warning disable 2196 // warning #2196: routine is both "inline" and "noinline"
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
72# endif
73#elif defined(__clang__)
74// Apple changes clang version macros to its Xcode version; the first Xcode release based on
75// (upstream) clang 3.3 was Xcode 5:
76# if __clang_major__ < 5
77# error pybind11 requires Xcode/clang 5.0 or newer
78# endif
79#elif defined(__GNUG__)
80# if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 8)
81# error pybind11 requires gcc 4.8 or newer
82# endif
83#elif defined(_MSC_VER)
84// Pybind hits various compiler bugs in 2015u2 and earlier, and also makes use of some stl features
85// (e.g. std::negation) added in 2015u3:
86# if _MSC_FULL_VER < 190024210
87# error pybind11 requires MSVC 2015 update 3 or newer
88# endif
89#endif
90
91#if !defined(PYBIND11_EXPORT)
92# if defined(WIN32) || defined(_WIN32)
93# define PYBIND11_EXPORT __declspec(dllexport)
94# else
95# define PYBIND11_EXPORT __attribute__((visibility("default")))
96# endif
97#endif
98
99#if !defined(PYBIND11_EXPORT_EXCEPTION)
100# ifdef __MINGW32__
101// workaround for:
102// error: 'dllexport' implies default visibility, but xxx has already been declared with a
103// different visibility
104# define PYBIND11_EXPORT_EXCEPTION
105# else
106# define PYBIND11_EXPORT_EXCEPTION PYBIND11_EXPORT
107# endif
108#endif
109
110// For CUDA, GCC7, GCC8:
111// PYBIND11_NOINLINE_FORCED is incompatible with `-Wattributes -Werror`.
112// When defining PYBIND11_NOINLINE_FORCED, it is best to also use `-Wno-attributes`.
113// However, the measured shared-library size saving when using noinline are only
114// 1.7% for CUDA, -0.2% for GCC7, and 0.0% for GCC8 (using -DCMAKE_BUILD_TYPE=MinSizeRel,
115// the default under pybind11/tests).
116#if !defined(PYBIND11_NOINLINE_FORCED) \
117 && (defined(__CUDACC__) || (defined(__GNUC__) && (__GNUC__ == 7 || __GNUC__ == 8)))
118# define PYBIND11_NOINLINE_DISABLED
119#endif
120
121// The PYBIND11_NOINLINE macro is for function DEFINITIONS.
122// In contrast, FORWARD DECLARATIONS should never use this macro:
123// https://stackoverflow.com/questions/9317473/forward-declaration-of-inline-functions
124#if defined(PYBIND11_NOINLINE_DISABLED) // Option for maximum portability and experimentation.
125# define PYBIND11_NOINLINE inline
126#elif defined(_MSC_VER)
127# define PYBIND11_NOINLINE __declspec(noinline) inline
128#else
129# define PYBIND11_NOINLINE __attribute__((noinline)) inline
130#endif
131
132#if defined(__MINGW32__)
133// For unknown reasons all PYBIND11_DEPRECATED member trigger a warning when declared
134// whether it is used or not
135# define PYBIND11_DEPRECATED(reason)
136#elif defined(PYBIND11_CPP14)
137# define PYBIND11_DEPRECATED(reason) [[deprecated(reason)]]
138#else
139# define PYBIND11_DEPRECATED(reason) __attribute__((deprecated(reason)))
140#endif
141
142#if defined(PYBIND11_CPP17)
143# define PYBIND11_MAYBE_UNUSED [[maybe_unused]]
144#elif defined(_MSC_VER) && !defined(__clang__)
145# define PYBIND11_MAYBE_UNUSED
146#else
147# define PYBIND11_MAYBE_UNUSED __attribute__((__unused__))
148#endif
149
150/* Don't let Python.h #define (v)snprintf as macro because they are implemented
151 properly in Visual Studio since 2015. */
152#if defined(_MSC_VER) && _MSC_VER >= 1900
153# define HAVE_SNPRINTF 1
154#endif
155
157#if defined(_MSC_VER)
158# pragma warning(push)
159// C4505: 'PySlice_GetIndicesEx': unreferenced local function has been removed (PyPy only)
160# pragma warning(disable : 4505)
161# if defined(_DEBUG) && !defined(Py_DEBUG)
162// Workaround for a VS 2022 issue.
163// NOTE: This workaround knowingly violates the Python.h include order requirement:
164// https://docs.python.org/3/c-api/intro.html#include-files
165// See https://github.com/pybind/pybind11/pull/3497 for full context.
166# include <yvals.h>
167# if _MSVC_STL_VERSION >= 143
168# include <crtdefs.h>
169# endif
170# define PYBIND11_DEBUG_MARKER
171# undef _DEBUG
172# endif
173#endif
174
175// https://en.cppreference.com/w/c/chrono/localtime
176#if defined(__STDC_LIB_EXT1__) && !defined(__STDC_WANT_LIB_EXT1__)
177# define __STDC_WANT_LIB_EXT1__
178#endif
179
180#ifdef __has_include
181// std::optional (but including it in c++14 mode isn't allowed)
182# if defined(PYBIND11_CPP17) && __has_include(<optional>)
183# define PYBIND11_HAS_OPTIONAL 1
184# endif
185// std::experimental::optional (but not allowed in c++11 mode)
186# if defined(PYBIND11_CPP14) && (__has_include(<experimental/optional>) && \
187 !__has_include(<optional>))
188# define PYBIND11_HAS_EXP_OPTIONAL 1
189# endif
190// std::variant
191# if defined(PYBIND11_CPP17) && __has_include(<variant>)
192# define PYBIND11_HAS_VARIANT 1
193# endif
194#elif defined(_MSC_VER) && defined(PYBIND11_CPP17)
195# define PYBIND11_HAS_OPTIONAL 1
196# define PYBIND11_HAS_VARIANT 1
197#endif
198
199#if defined(PYBIND11_CPP17)
200# if defined(__has_include)
201# if __has_include(<string_view>)
202# define PYBIND11_HAS_STRING_VIEW
203# endif
204# elif defined(_MSC_VER)
205# define PYBIND11_HAS_STRING_VIEW
206# endif
207#endif
208
209#if defined(__cpp_lib_char8_t) && __cpp_lib_char8_t >= 201811L
210# define PYBIND11_HAS_U8STRING
211#endif
212
213#include <Python.h>
214#include <frameobject.h>
215#include <pythread.h>
216
217/* Python #defines overrides on all sorts of core functions, which
218 tends to weak havok in C++ codebases that expect these to work
219 like regular functions (potentially with several overloads) */
220#if defined(isalnum)
221# undef isalnum
222# undef isalpha
223# undef islower
224# undef isspace
225# undef isupper
226# undef tolower
227# undef toupper
228#endif
229
230#if defined(copysign)
231# undef copysign
232#endif
233
234#if defined(_MSC_VER)
235# if defined(PYBIND11_DEBUG_MARKER)
236# define _DEBUG
237# undef PYBIND11_DEBUG_MARKER
238# endif
239# pragma warning(pop)
240#endif
241
242#include <cstddef>
243#include <cstring>
244#include <exception>
245#include <forward_list>
246#include <memory>
247#include <stdexcept>
248#include <string>
249#include <type_traits>
250#include <typeindex>
251#include <unordered_map>
252#include <unordered_set>
253#include <vector>
254#if defined(__has_include)
255# if __has_include(<version>)
256# include <version>
257# endif
258#endif
259
260// #define PYBIND11_STR_LEGACY_PERMISSIVE
261// If DEFINED, pybind11::str can hold PyUnicodeObject or PyBytesObject
262// (probably surprising and never documented, but this was the
263// legacy behavior until and including v2.6.x). As a side-effect,
264// pybind11::isinstance<str>() is true for both pybind11::str and
265// pybind11::bytes.
266// If UNDEFINED, pybind11::str can only hold PyUnicodeObject, and
267// pybind11::isinstance<str>() is true only for pybind11::str.
268// However, for Python 2 only (!), the pybind11::str caster
269// implicitly decodes bytes to PyUnicodeObject. This is to ease
270// the transition from the legacy behavior to the non-permissive
271// behavior.
272
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"
295// Providing a separate declaration to make Clang's -Wmissing-prototypes happy.
296// See comment for PYBIND11_MODULE below for why this is marked "maybe unused".
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()
300
301#else
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) // Returns long if needed.
315# define PYBIND11_LONG_FROM_UNSIGNED(o) PyInt_FromSize_t((size_t) o) // Returns long if needed.
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__"
324// Providing a separate PyInit decl to make Clang's -Wmissing-prototypes happy.
325// See comment for PYBIND11_MODULE below for why this is marked "maybe unused".
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()
331#endif
332
333#if PY_VERSION_HEX >= 0x03050000 && PY_VERSION_HEX < 0x03050200
334extern "C" {
335struct _Py_atomic_address {
336 void *value;
337};
338PyAPI_DATA(_Py_atomic_address) _PyThreadState_Current;
339}
340#endif
341
342#define PYBIND11_TRY_NEXT_OVERLOAD ((PyObject *) 1) // special failure return code
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();
347
348#define PYBIND11_CHECK_PYTHON_VERSION \
349 { \
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.", \
359 compiled_ver, \
360 runtime_ver); \
361 return nullptr; \
362 } \
363 }
364
365#if PY_VERSION_HEX >= 0x03030000
366
367# define PYBIND11_CATCH_INIT_EXCEPTIONS \
368 catch (pybind11::error_already_set & e) { \
369 pybind11::raise_from(e, PyExc_ImportError, "initialization failed"); \
370 return nullptr; \
371 } \
372 catch (const std::exception &e) { \
373 PyErr_SetString(PyExc_ImportError, e.what()); \
374 return nullptr; \
375 }
376
377#else
378
379# define PYBIND11_CATCH_INIT_EXCEPTIONS \
380 catch (pybind11::error_already_set & e) { \
381 PyErr_SetString(PyExc_ImportError, e.what()); \
382 return nullptr; \
383 } \
384 catch (const std::exception &e) { \
385 PyErr_SetString(PyExc_ImportError, e.what()); \
386 return nullptr; \
387 }
388
389#endif
390
403
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 \
412 try { \
413 return pybind11_init(); \
414 } \
415 PYBIND11_CATCH_INIT_EXCEPTIONS \
416 } \
417 PyObject *pybind11_init()
418
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)); \
450 try { \
451 PYBIND11_CONCAT(pybind11_init_, name)(m); \
452 return m.ptr(); \
453 } \
454 PYBIND11_CATCH_INIT_EXCEPTIONS \
455 } \
456 void PYBIND11_CONCAT(pybind11_init_, name)(::pybind11::module_ & (variable))
457
459
460using ssize_t = Py_ssize_t;
461using size_t = std::size_t;
462
463template <typename IntType>
464inline ssize_t ssize_t_cast(const IntType &val) {
465 static_assert(sizeof(IntType) <= sizeof(ssize_t), "Implicit narrowing is not permitted.");
466 return static_cast<ssize_t>(val);
467}
468
470enum class return_value_policy : uint8_t {
476 automatic = 0,
477
483
489
493 copy,
494
499 move,
500
506 reference,
507
519};
520
522
523inline static constexpr int log2(size_t n, int k = 0) {
524 return (n <= 1) ? k : log2(n >> 1, k + 1);
525}
526
527// Returns the size as a multiple of sizeof(void *), rounded up.
528inline static constexpr size_t size_in_ptrs(size_t s) {
529 return 1 + ((s - 1) >> log2(sizeof(void *)));
530}
531
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");
541 return size_in_ptrs(sizeof(std::shared_ptr<int>));
542}
543
544// Forward declarations
545struct type_info;
546struct value_and_holder;
547
550 uint8_t *status;
551};
552
554struct instance {
555 PyObject_HEAD
557 union {
560 };
562 PyObject *weakrefs;
564 bool owned : 1;
594 bool has_patients : 1;
595
598 void allocate_layout();
599
601 void deallocate_layout();
602
606 value_and_holder get_value_and_holder(const type_info *find_type = nullptr,
607 bool throw_if_missing = true);
608
610 static constexpr uint8_t status_holder_constructed = 1;
611 static constexpr uint8_t status_instance_registered = 2;
612};
613
614static_assert(std::is_standard_layout<instance>::value,
615 "Internal error: `pybind11::detail::instance` is not standard layout!");
616
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;
623#else
624template <bool B, typename T = void>
625using enable_if_t = typename std::enable_if<B, T>::type;
626template <bool B, typename T, typename F>
627using conditional_t = typename std::conditional<B, T, F>::type;
628template <typename T>
629using remove_cv_t = typename std::remove_cv<T>::type;
630template <typename T>
631using remove_reference_t = typename std::remove_reference<T>::type;
632#endif
633
634#if defined(PYBIND11_CPP20)
635using std::remove_cvref;
636using std::remove_cvref_t;
637#else
638template <class T>
641};
642template <class T>
644#endif
645
647#if defined(PYBIND11_CPP14)
648using std::index_sequence;
649using std::make_index_sequence;
650#else
651template <size_t...>
653template <size_t N, size_t... S>
655template <size_t... S>
657 using type = index_sequence<S...>;
658};
659template <size_t N>
661#endif
662
664template <typename ISeq, size_t, bool...>
666 using type = ISeq;
667};
668template <size_t... IPrev, size_t I, bool B, bool... Bs>
669struct select_indices_impl<index_sequence<IPrev...>, I, B, Bs...>
670 : select_indices_impl<conditional_t<B, index_sequence<IPrev..., I>, index_sequence<IPrev...>>,
671 I + 1,
672 Bs...> {};
673template <bool... Bs>
675
677template <bool B>
678using bool_constant = std::integral_constant<bool, B>;
679template <typename T>
680struct negation : bool_constant<!T::value> {};
681
682// PGI/Intel cannot detect operator delete with the "compatible" void_t impl, so
683// using the new one (C++14 defect, so generally works on newer compilers, even
684// if not in C++17 mode)
685#if defined(__PGIC__) || defined(__INTEL_COMPILER)
686template <typename...>
687using void_t = void;
688#else
689template <typename...>
691 using type = void;
692};
693template <typename... Ts>
694using void_t = typename void_t_impl<Ts...>::type;
695#endif
696
698#if defined(__cpp_fold_expressions) && !(defined(_MSC_VER) && (_MSC_VER < 1916))
699template <class... Ts>
700using all_of = bool_constant<(Ts::value && ...)>;
701template <class... Ts>
702using any_of = bool_constant<(Ts::value || ...)>;
703#elif !defined(_MSC_VER)
704template <bool...>
705struct bools {};
706template <class... Ts>
707using all_of = std::is_same<bools<Ts::value..., true>, bools<true, Ts::value...>>;
708template <class... Ts>
710#else
711// MSVC has trouble with the above, but supports std::conjunction, which we can use instead (albeit
712// at a slight loss of compilation efficiency).
713template <class... Ts>
714using all_of = std::conjunction<Ts...>;
715template <class... Ts>
716using any_of = std::disjunction<Ts...>;
717#endif
718template <class... Ts>
719using none_of = negation<any_of<Ts...>>;
720
721template <class T, template <class> class... Predicates>
723template <class T, template <class> class... Predicates>
725template <class T, template <class> class... Predicates>
727
729template <typename T>
730struct remove_class {};
731template <typename C, typename R, typename... A>
732struct remove_class<R (C::*)(A...)> {
733 using type = R(A...);
734};
735template <typename C, typename R, typename... A>
736struct remove_class<R (C::*)(A...) const> {
737 using type = R(A...);
738};
739
741template <typename T>
743 using type = T;
744};
745template <typename T>
746struct intrinsic_type<const T> {
748};
749template <typename T>
750struct intrinsic_type<T *> {
752};
753template <typename T>
754struct intrinsic_type<T &> {
756};
757template <typename T>
758struct intrinsic_type<T &&> {
760};
761template <typename T, size_t N>
762struct intrinsic_type<const T[N]> {
764};
765template <typename T, size_t N>
766struct intrinsic_type<T[N]> {
768};
769template <typename T>
771
773struct void_type {};
774
776template <typename...>
777struct type_list {};
778
780#ifdef __cpp_fold_expressions
781template <typename... Ts>
782constexpr size_t constexpr_sum(Ts... ns) {
783 return (0 + ... + size_t{ns});
784}
785#else
786constexpr size_t constexpr_sum() { return 0; }
787template <typename T, typename... Ts>
788constexpr size_t constexpr_sum(T n, Ts... ns) {
789 return size_t{n} + constexpr_sum(ns...);
790}
791#endif
792
793PYBIND11_NAMESPACE_BEGIN(constexpr_impl)
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...);
799}
800
801constexpr int last(int /*i*/, 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...);
805}
806PYBIND11_NAMESPACE_END(constexpr_impl)
807
808
810template <template <typename> class Predicate, typename... Ts>
811constexpr int constexpr_first() {
812 return constexpr_impl::first(0, Predicate<Ts>::value...);
813}
814
816template <template <typename> class Predicate, typename... Ts>
817constexpr int constexpr_last() {
818 return constexpr_impl::last(0, -1, Predicate<Ts>::value...);
819}
820
822template <size_t N, typename T, typename... Ts>
824 using type = typename pack_element<N - 1, Ts...>::type;
825};
826template <typename T, typename... Ts>
827struct pack_element<0, T, Ts...> {
828 using type = T;
829};
830
833template <template <typename> class Predicate, typename Default, typename... Ts>
835 static constexpr auto found = constexpr_sum(Predicate<Ts>::value...);
836 static_assert(found <= 1, "Found more than one type matching the predicate");
837
838 static constexpr auto index = found ? constexpr_first<Predicate, Ts...>() : 0;
839 using type = conditional_t<found, typename pack_element<index, Ts...>::type, Default>;
840};
841template <template <typename> class P, typename Default>
842struct exactly_one<P, Default> {
843 using type = Default;
844};
845
846template <template <typename> class Predicate, typename Default, typename... Ts>
847using exactly_one_t = typename exactly_one<Predicate, Default, Ts...>::type;
848
850template <typename T, typename... /*Us*/>
852 using type = T;
853};
854template <typename T, typename... Us>
855using deferred_t = typename deferred_type<T, Us...>::type;
856
859template <typename Base, typename Derived>
861 = bool_constant<std::is_base_of<Base, Derived>::value && !std::is_same<Base, Derived>::value>;
862
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>;
870
871template <template <typename...> class Base>
873 template <typename... Us>
874 static std::true_type check(Base<Us...> *);
875 static std::false_type check(...);
876};
877
880template <template <typename...> class Base, typename T>
881#if !defined(_MSC_VER)
884#else // MSVC2015 has trouble with decltype in template aliases
886 : decltype(is_template_base_of_impl<Base>::check((intrinsic_t<T> *) nullptr)) {
887};
888#endif
889
892template <template <typename...> class Class, typename T>
893struct is_instantiation : std::false_type {};
894template <template <typename...> class Class, typename... Us>
895struct is_instantiation<Class, Class<Us...>> : std::true_type {};
896
898template <typename T>
900
902template <typename T, typename = void>
903struct is_input_iterator : std::false_type {};
904template <typename T>
906 void_t<decltype(*std::declval<T &>()), decltype(++std::declval<T &>())>>
907 : std::true_type {};
908
909template <typename T>
912 && std::is_function<typename std::remove_pointer<T>::type>::value>;
913
914template <typename F>
916 // If you are encountering an
917 // 'error: name followed by "::" must be a class or namespace name'
918 // with the Intel compiler and a noexcept function here,
919 // try to use noexcept(true) instead of plain noexcept.
920 using type = typename remove_class<decltype(&F::operator())>::type;
921};
922
923// Extracts the function signature from a function, function pointer or lambda.
924template <typename Function, typename F = remove_reference_t<Function>>
926 std::is_function<F>::value,
927 F,
928 typename conditional_t<std::is_pointer<F>::value || std::is_member_pointer<F>::value,
929 std::remove_pointer<F>,
931
935template <typename T>
937 std::is_function,
938 std::is_pointer,
939 std::is_member_pointer>;
940
941// [workaround(intel)] Internal error on fold expression
943#if defined(__cpp_fold_expressions) && !defined(__INTEL_COMPILER)
944// Intel compiler produces an internal error on this fold expression (tested with ICC 19.0.2)
945# define PYBIND11_EXPAND_SIDE_EFFECTS(PATTERN) (((PATTERN), void()), ...)
946#else
947using expand_side_effects = bool[];
948# define PYBIND11_EXPAND_SIDE_EFFECTS(PATTERN) \
949 (void) pybind11::detail::expand_side_effects { ((PATTERN), void(), false)..., false }
950#endif
951
953
954#if defined(_MSC_VER)
955# pragma warning(push)
956# pragma warning(disable : 4275)
957// warning C4275: An exported class was derived from a class that wasn't exported.
958// Can be ignored when derived from a STL class.
959#endif
961class PYBIND11_EXPORT_EXCEPTION builtin_exception : public std::runtime_error {
962public:
963 using std::runtime_error::runtime_error;
965 virtual void set_error() const = 0;
966};
967#if defined(_MSC_VER)
968# pragma warning(pop)
969#endif
970
971#define PYBIND11_RUNTIME_EXCEPTION(name, type) \
972 class PYBIND11_EXPORT_EXCEPTION name : public builtin_exception { \
973 public: \
974 using builtin_exception::builtin_exception; \
975 name() : name("") {} \
976 void set_error() const override { PyErr_SetString(type, what()); } \
977 };
978
979PYBIND11_RUNTIME_EXCEPTION(stop_iteration, PyExc_StopIteration)
980PYBIND11_RUNTIME_EXCEPTION(index_error, PyExc_IndexError)
981PYBIND11_RUNTIME_EXCEPTION(key_error, PyExc_KeyError)
982PYBIND11_RUNTIME_EXCEPTION(value_error, PyExc_ValueError)
983PYBIND11_RUNTIME_EXCEPTION(type_error, PyExc_TypeError)
984PYBIND11_RUNTIME_EXCEPTION(buffer_error, PyExc_BufferError)
985PYBIND11_RUNTIME_EXCEPTION(import_error, PyExc_ImportError)
986PYBIND11_RUNTIME_EXCEPTION(attribute_error, PyExc_AttributeError)
987PYBIND11_RUNTIME_EXCEPTION(cast_error, PyExc_RuntimeError)
990PYBIND11_RUNTIME_EXCEPTION(reference_cast_error, PyExc_RuntimeError)
991
992[[noreturn]] PYBIND11_NOINLINE void pybind11_fail(const char *reason) {
993 throw std::runtime_error(reason);
994}
995[[noreturn]] PYBIND11_NOINLINE void pybind11_fail(const std::string &reason) {
996 throw std::runtime_error(reason);
997}
998
999template <typename T, typename SFINAE = void>
1001
1003// Returns the index of the given type in the type char array below, and in the list in numpy.h
1004// The order here is: bool; 8 ints ((signed,unsigned)x(8,16,32,64)bits); float,double,long double;
1005// complex float,double,long double. Note that the long double types only participate when long
1006// double is actually longer than double (it isn't under MSVC).
1007// NB: not only the string below but also complex.h and numpy.h rely on this order.
1008template <typename T, typename SFINAE = void>
1010 static constexpr bool value = false;
1011};
1012template <typename T>
1013struct is_fmt_numeric<T, enable_if_t<std::is_arithmetic<T>::value>> {
1014 static constexpr bool value = true;
1015 static constexpr int index
1016 = std::is_same<T, bool>::value
1017 ? 0
1018 : 1
1019 + (std::is_integral<T>::value
1020 ? detail::log2(sizeof(T)) * 2 + std::is_unsigned<T>::value
1021 : 8
1022 + (std::is_same<T, double>::value ? 1
1023 : std::is_same<T, long double>::value ? 2
1024 : 0));
1025};
1027
1028template <typename T>
1029struct format_descriptor<T, detail::enable_if_t<std::is_arithmetic<T>::value>> {
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); }
1033};
1034
1035#if !defined(PYBIND11_CPP17)
1036
1037template <typename T>
1038constexpr const char
1040
1041#endif
1042
1045 PyObject *type, *value, *trace;
1046 error_scope() { PyErr_Fetch(&type, &value, &trace); }
1047 ~error_scope() { PyErr_Restore(type, value, trace); }
1048};
1049
1051struct nodelete {
1052 template <typename T>
1053 void operator()(T *) {}
1054};
1055
1057template <typename... Args>
1059 // NOLINTNEXTLINE(modernize-use-equals-default): MSVC 2015 needs this
1060 constexpr overload_cast_impl() {}
1061
1062 template <typename Return>
1063 constexpr auto operator()(Return (*pf)(Args...)) const noexcept -> decltype(pf) {
1064 return pf;
1065 }
1066
1067 template <typename Return, typename Class>
1068 constexpr auto operator()(Return (Class::*pmf)(Args...), std::false_type = {}) const noexcept
1069 -> decltype(pmf) {
1070 return pmf;
1071 }
1072
1073 template <typename Return, typename Class>
1074 constexpr auto operator()(Return (Class::*pmf)(Args...) const, std::true_type) const noexcept
1075 -> decltype(pmf) {
1076 return pmf;
1077 }
1078};
1080
1081// overload_cast requires variable templates: C++14
1082#if defined(PYBIND11_CPP14)
1083# define PYBIND11_OVERLOAD_CAST 1
1087template <typename... Args>
1088static constexpr detail::overload_cast_impl<Args...> overload_cast = {};
1089// MSVC 2015 only accepts this particular initialization syntax for this variable template.
1090#endif
1091
1095static constexpr auto const_ = std::true_type{};
1096
1097#if !defined(PYBIND11_CPP14) // no overload_cast: providing something that static_assert-fails:
1098template <typename... Args>
1100 static_assert(detail::deferred_t<std::false_type, Args...>::value,
1101 "pybind11::overload_cast<...> requires compiling in C++14 mode");
1102};
1103#endif // overload_cast
1104
1106
1107// Adaptor for converting arbitrary container arguments into a vector; implicitly convertible from
1108// any standard container (or C-style array) supporting std::begin/std::end, any singleton
1109// arithmetic type (if T is arithmetic), or explicitly constructible from an iterator pair.
1110template <typename T>
1112 std::vector<T> v;
1113
1114public:
1115 any_container() = default;
1116
1117 // Can construct from a pair of iterators
1118 template <typename It, typename = enable_if_t<is_input_iterator<It>::value>>
1120
1121 // Implicit conversion constructor from any arbitrary container type
1122 // with values convertible to T
1123 template <typename Container,
1124 typename = enable_if_t<
1125 std::is_convertible<decltype(*std::begin(std::declval<const Container &>())),
1126 T>::value>>
1127 // NOLINTNEXTLINE(google-explicit-constructor)
1128 any_container(const Container &c) : any_container(std::begin(c), std::end(c)) {}
1129
1130 // initializer_list's aren't deducible, so don't get matched by the above template;
1131 // we need this to explicitly allow implicit conversion from one:
1132 template <typename TIn, typename = enable_if_t<std::is_convertible<TIn, T>::value>>
1133 any_container(const std::initializer_list<TIn> &c) : any_container(c.begin(), c.end()) {}
1134
1135 // Avoid copying if given an rvalue vector of the correct type.
1136 // NOLINTNEXTLINE(google-explicit-constructor)
1137 any_container(std::vector<T> &&v) : v(std::move(v)) {}
1138
1139 // Moves the vector out of an rvalue any_container
1140 // NOLINTNEXTLINE(google-explicit-constructor)
1141 operator std::vector<T> &&() && { return std::move(v); }
1142
1143 // Dereferencing obtains a reference to the underlying vector
1144 std::vector<T> &operator*() { return v; }
1145 const std::vector<T> &operator*() const { return v; }
1146
1147 // -> lets you call methods on the underlying vector
1148 std::vector<T> *operator->() { return &v; }
1149 const std::vector<T> *operator->() const { return &v; }
1150};
1151
1152// Forward-declaration; see detail/class.h
1153std::string get_fully_qualified_tp_name(PyTypeObject *);
1154
1155template <typename T>
1156inline static std::shared_ptr<T>
1157try_get_shared_from_this(std::enable_shared_from_this<T> *holder_value_ptr) {
1158// Pre C++17, this code path exploits undefined behavior, but is known to work on many platforms.
1159// Use at your own risk!
1160// See also https://en.cppreference.com/w/cpp/memory/enable_shared_from_this, and in particular
1161// the `std::shared_ptr<Good> gp1 = not_so_good.getptr();` and `try`-`catch` parts of the example.
1162#if defined(__cpp_lib_enable_shared_from_this) && (!defined(_MSC_VER) || _MSC_VER >= 1912)
1163 return holder_value_ptr->weak_from_this().lock();
1164#else
1165 try {
1166 return holder_value_ptr->shared_from_this();
1167 } catch (const std::bad_weak_ptr &) {
1168 return nullptr;
1169 }
1170#endif
1171}
1172
1173// For silencing "unused" compiler warnings in special situations.
1174template <typename... Args>
1175#if defined(_MSC_VER) && _MSC_VER >= 1910 && _MSC_VER < 1920 // MSVC 2017
1176constexpr
1177#endif
1178 inline void
1180}
1181
1182// MSVC warning C4100: Unreferenced formal parameter
1183#if defined(_MSC_VER) && _MSC_VER <= 1916
1184# define PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(...) \
1185 detail::silence_unused_warnings(__VA_ARGS__)
1186#else
1187# define PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(...)
1188#endif
1189
1190// GCC -Wunused-but-set-parameter All GCC versions (as of July 2021).
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__)
1194#else
1195# define PYBIND11_WORKAROUND_INCORRECT_GCC_UNUSED_BUT_SET_PARAMETER(...)
1196#endif
1197
1198#if defined(_MSC_VER) // All versions (as of July 2021).
1199
1200// warning C4127: Conditional expression is constant
1201constexpr inline bool silence_msvc_c4127(bool cond) { return cond; }
1202
1203# define PYBIND11_SILENCE_MSVC_C4127(...) ::pybind11::detail::silence_msvc_c4127(__VA_ARGS__)
1204
1205#else
1206# define PYBIND11_SILENCE_MSVC_C4127(...) __VA_ARGS__
1207#endif
1208
any_container(It first, It last)
Definition: common.h:1119
std::vector< T > * operator->()
Definition: common.h:1148
any_container(const Container &c)
Definition: common.h:1128
std::vector< T > & operator*()
Definition: common.h:1144
any_container(std::vector< T > &&v)
Definition: common.h:1137
any_container(const std::initializer_list< TIn > &c)
Definition: common.h:1133
const std::vector< T > & operator*() const
Definition: common.h:1145
const std::vector< T > * operator->() const
Definition: common.h:1149
std::vector< T > v
Definition: common.h:1112
any_container()=default
C++ bindings of builtin Python exceptions.
Definition: common.h:961
virtual void set_error() const =0
Set the error using the Python C API.
Definition: pytypes.h:1167
typename std::enable_if< B, T >::type enable_if_t
from cpp_future import (convenient aliases from C++14/17)
Definition: common.h:625
std::string get_fully_qualified_tp_name(PyTypeObject *)
Definition: class.h:28
typename deferred_type< T, Us... >::type deferred_t
Definition: common.h:855
std::integral_constant< bool, B > bool_constant
Backports of std::bool_constant and std::negation to accommodate older compilers.
Definition: common.h:678
constexpr int last(int, int result)
Definition: common.h:801
static constexpr size_t size_in_ptrs(size_t s)
Definition: common.h:528
PYBIND11_NOINLINE void pybind11_fail(const char *reason)
Thrown when pybind11::cast or.
Definition: common.h:992
#define PYBIND11_NOINLINE
Definition: common.h:129
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...
Definition: common.h:538
void silence_unused_warnings(Args &&...)
Definition: common.h:1179
typename std::remove_reference< T >::type remove_reference_t
Definition: common.h:631
constexpr int constexpr_first()
Return the index of the first type in Ts which satisfies Predicate<T>.
Definition: common.h:811
typename remove_cvref< T >::type remove_cvref_t
Definition: common.h:643
static std::shared_ptr< T > try_get_shared_from_this(std::enable_shared_from_this< T > *holder_value_ptr)
Definition: common.h:1157
typename intrinsic_type< T >::type intrinsic_t
Definition: common.h:770
bool_constant< std::is_pointer< T >::value &&std::is_function< typename std::remove_pointer< T >::type >::value > is_function_pointer
Definition: common.h:912
all_of< Predicates< T >... > satisfies_all_of
Definition: common.h:722
#define PYBIND11_EXPORT_EXCEPTION
Definition: common.h:106
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.
Definition: common.h:883
constexpr int first(int i)
Implementation details for constexpr functions.
Definition: common.h:795
static constexpr auto const_
Const member function selector for overload_cast.
Definition: common.h:1095
static constexpr int log2(size_t n, int k=0)
Definition: common.h:523
std::size_t size_t
Definition: common.h:461
constexpr size_t constexpr_sum()
Compile-time integer sum.
Definition: common.h:786
#define PYBIND11_RUNTIME_EXCEPTION(name, type)
Definition: common.h:971
typename std::remove_cv< T >::type remove_cv_t
Definition: common.h:629
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.
Definition: common.h:869
#define PYBIND11_NAMESPACE_END(name)
Definition: common.h:21
typename exactly_one< Predicate, Default, Ts... >::type exactly_one_t
Definition: common.h:847
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
Definition: common.h:930
#define PYBIND11_NAMESPACE_BEGIN(name)
Definition: common.h:20
typename make_index_sequence_impl< N >::type make_index_sequence
Definition: common.h:660
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.
Definition: common.h:861
Py_ssize_t ssize_t
Definition: common.h:460
typename void_t_impl< Ts... >::type void_t
Definition: common.h:694
std::is_same< bools< Ts::value..., true >, bools< true, Ts::value... > > all_of
Definition: common.h:707
typename std::conditional< B, T, F >::type conditional_t
Definition: common.h:627
constexpr int constexpr_last()
Return the index of the last type in Ts which satisfies Predicate<T>, or -1 if none match.
Definition: common.h:817
return_value_policy
Approach used to cast a previously unknown C++ instance into a Python object.
Definition: common.h:470
@ 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)
Definition: common.h:464
bool[] expand_side_effects
Apply a function over each element of a parameter pack.
Definition: common.h:947
typename select_indices_impl< index_sequence<>, 0, Bs... >::type select_indices
Definition: common.h:674
typename std::enable_if< B, T >::type enable_if_t
from cpp_future import (convenient aliases from C++14/17)
Definition: common.h:644
std::integral_constant< bool, B > bool_constant
Backports of std::bool_constant and std::negation to accommodate older compilers.
Definition: common.h:697
constexpr int last(int, int result)
Definition: common.h:820
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...
Definition: common.h:557
constexpr int constexpr_first()
Return the index of the first type in Ts which satisfies Predicate<T>.
Definition: common.h:830
constexpr int first(int i)
Implementation details for constexpr functions.
Definition: common.h:814
constexpr size_t constexpr_sum()
Compile-time integer sum.
Definition: common.h:805
typename std::remove_cv< T >::type remove_cv_t
Definition: common.h:648
typename void_t_impl< Ts... >::type void_t
Definition: common.h:713
typename std::conditional< B, T, F >::type conditional_t
Definition: common.h:646
@ 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.
Definition: common.h:705
Defer the evaluation of type T until types Us are instantiated.
Definition: common.h:851
RAII wrapper that temporarily clears any Python error state.
Definition: common.h:1044
PyObject * value
Definition: common.h:1045
error_scope()
Definition: common.h:1046
PyObject * type
Definition: common.h:1045
PyObject * trace
Definition: common.h:1045
~error_scope()
Definition: common.h:1047
Return the one and only type which matches the predicate, or Default if none match.
Definition: common.h:834
static constexpr auto index
Definition: common.h:838
static constexpr auto found
Definition: common.h:835
conditional_t< found, typename pack_element< index, Ts... >::type, Default > type
Definition: common.h:839
Index sequences.
Definition: common.h:652
The 'instance' type which needs to be standard layout (need to be able to use 'offsetof')
Definition: common.h:554
nonsimple_values_and_holders nonsimple
Definition: common.h:559
void deallocate_layout()
Destroys/deallocates all of the above.
bool simple_layout
An instance has two possible value/holder layouts.
Definition: common.h:588
bool has_patients
If true, get_internals().patients has an entry for this object.
Definition: common.h:594
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.
Definition: common.h:562
void * simple_value_holder[1+instance_simple_holder_in_ptrs()]
Definition: common.h:558
bool simple_instance_registered
For simple layout, tracks whether the instance is registered in registered_instances
Definition: common.h:592
bool owned
If true, the pointer is owned which means we're free to manage it with a holder.
Definition: common.h:564
static constexpr uint8_t status_instance_registered
Definition: common.h:611
bool simple_holder_constructed
For simple layout, tracks whether the holder has been constructed.
Definition: common.h:590
static constexpr uint8_t status_holder_constructed
Bit values for the non-simple status flags.
Definition: common.h:610
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.
Definition: common.h:742
static constexpr bool value
Definition: common.h:1010
Check if T looks like an input iterator.
Definition: common.h:903
Check if T is an instantiation of the template Class.
Definition: common.h:893
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.
Definition: common.h:1051
void operator()(T *)
Definition: common.h:1053
constexpr auto operator()(Return(*pf)(Args...)) const noexcept -> decltype(pf)
Definition: common.h:1063
constexpr auto operator()(Return(Class::*pmf)(Args...), std::false_type={}) const noexcept -> decltype(pmf)
Definition: common.h:1068
constexpr auto operator()(Return(Class::*pmf)(Args...) const, std::true_type) const noexcept -> decltype(pmf)
Definition: common.h:1074
constexpr overload_cast_impl()
Definition: common.h:1060
Return the Nth element from the parameter pack.
Definition: common.h:823
typename pack_element< N - 1, Ts... >::type type
Definition: common.h:824
Strip the class from a method type.
Definition: common.h:730
remove_cv_t< remove_reference_t< T > > type
Definition: common.h:640
Make an index sequence of the indices of true arguments.
Definition: common.h:665
Additional type information which does not fit into the PyTypeObject.
Definition: internals.h:196
Helper template which holds a list of types.
Definition: common.h:777
Helper type to replace 'void' in some expressions.
Definition: common.h:773