wrap/pybind11/include/pybind11/detail/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 11
14 #define PYBIND11_VERSION_PATCH 1
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 0x020B0100
19 
20 // Define some generic pybind11 helper macros for warning management.
21 //
22 // Note that compiler-specific push/pop pairs are baked into the
23 // PYBIND11_NAMESPACE_BEGIN/PYBIND11_NAMESPACE_END pair of macros. Therefore manual
24 // PYBIND11_WARNING_PUSH/PYBIND11_WARNING_POP are usually only needed in `#include` sections.
25 //
26 // If you find you need to suppress a warning, please try to make the suppression as local as
27 // possible using these macros. Please also be sure to push/pop with the pybind11 macros. Please
28 // only use compiler specifics if you need to check specific versions, e.g. Apple Clang vs. vanilla
29 // Clang.
30 #if defined(_MSC_VER)
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)
50 #endif
51 
52 #ifdef PYBIND11_COMPILER_MSVC
53 # define PYBIND11_WARNING_DISABLE_MSVC(name) PYBIND11_PRAGMA(warning(disable : name))
54 #else
55 # define PYBIND11_WARNING_DISABLE_MSVC(name)
56 #endif
57 
58 #ifdef PYBIND11_COMPILER_CLANG
59 # define PYBIND11_WARNING_DISABLE_CLANG(name) PYBIND11_PRAGMA(clang diagnostic ignored name)
60 #else
61 # define PYBIND11_WARNING_DISABLE_CLANG(name)
62 #endif
63 
64 #ifdef PYBIND11_COMPILER_GCC
65 # define PYBIND11_WARNING_DISABLE_GCC(name) PYBIND11_PRAGMA(GCC diagnostic ignored name)
66 #else
67 # define PYBIND11_WARNING_DISABLE_GCC(name)
68 #endif
69 
70 #ifdef PYBIND11_COMPILER_INTEL
71 # define PYBIND11_WARNING_DISABLE_INTEL(name) PYBIND11_PRAGMA(warning disable name)
72 #else
73 # define PYBIND11_WARNING_DISABLE_INTEL(name)
74 #endif
75 
76 #define PYBIND11_NAMESPACE_BEGIN(name) \
77  namespace name { \
78  PYBIND11_WARNING_PUSH
79 
80 #define PYBIND11_NAMESPACE_END(name) \
81  PYBIND11_WARNING_POP \
82  }
83 
84 // Robust support for some features and loading modules compiled against different pybind versions
85 // requires forcing hidden visibility on pybind code, so we enforce this by setting the attribute
86 // on the main `pybind11` namespace.
87 #if !defined(PYBIND11_NAMESPACE)
88 # ifdef __GNUG__
89 # define PYBIND11_NAMESPACE pybind11 __attribute__((visibility("hidden")))
90 # else
91 # define PYBIND11_NAMESPACE pybind11
92 # endif
93 #endif
94 
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
102 // Please update tests/pybind11_tests.cpp `cpp_std()` when adding a macro here.
103 # endif
104 # endif
105 # endif
106 #elif defined(_MSC_VER) && __cplusplus == 199711L
107 // MSVC sets _MSVC_LANG rather than __cplusplus (supposedly until the standard is fully
108 // implemented). Unless you use the /Zc:__cplusplus flag on Visual Studio 2017 15.7 Preview 3
109 // or newer.
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
116 # endif
117 # endif
118 # endif
119 #endif
120 
121 // Compiler version assertions
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.
127 # endif
128 /* The following pragma cannot be pop'ed:
129  https://community.intel.com/t5/Intel-C-Compiler/Inline-and-no-inline-warning/td-p/1216764 */
130 # pragma warning disable 2196 // warning #2196: routine is both "inline" and "noinline"
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
134 # endif
135 #elif defined(__clang__)
136 // Apple changes clang version macros to its Xcode version; the first Xcode release based on
137 // (upstream) clang 3.3 was Xcode 5:
138 # if __clang_major__ < 5
139 # error pybind11 requires Xcode/clang 5.0 or newer
140 # endif
141 #elif defined(__GNUG__)
142 # if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 8)
143 # error pybind11 requires gcc 4.8 or newer
144 # endif
145 #elif defined(_MSC_VER)
146 # if _MSC_VER < 1910
147 # error pybind11 2.10+ requires MSVC 2017 or newer
148 # endif
149 #endif
150 
151 #if !defined(PYBIND11_EXPORT)
152 # if defined(WIN32) || defined(_WIN32)
153 # define PYBIND11_EXPORT __declspec(dllexport)
154 # else
155 # define PYBIND11_EXPORT __attribute__((visibility("default")))
156 # endif
157 #endif
158 
159 #if !defined(PYBIND11_EXPORT_EXCEPTION)
160 # if defined(__apple_build_version__)
161 # define PYBIND11_EXPORT_EXCEPTION PYBIND11_EXPORT
162 # else
163 # define PYBIND11_EXPORT_EXCEPTION
164 # endif
165 #endif
166 
167 // For CUDA, GCC7, GCC8:
168 // PYBIND11_NOINLINE_FORCED is incompatible with `-Wattributes -Werror`.
169 // When defining PYBIND11_NOINLINE_FORCED, it is best to also use `-Wno-attributes`.
170 // However, the measured shared-library size saving when using noinline are only
171 // 1.7% for CUDA, -0.2% for GCC7, and 0.0% for GCC8 (using -DCMAKE_BUILD_TYPE=MinSizeRel,
172 // the default under pybind11/tests).
173 #if !defined(PYBIND11_NOINLINE_FORCED) \
174  && (defined(__CUDACC__) || (defined(__GNUC__) && (__GNUC__ == 7 || __GNUC__ == 8)))
175 # define PYBIND11_NOINLINE_DISABLED
176 #endif
177 
178 // The PYBIND11_NOINLINE macro is for function DEFINITIONS.
179 // In contrast, FORWARD DECLARATIONS should never use this macro:
180 // https://stackoverflow.com/questions/9317473/forward-declaration-of-inline-functions
181 #if defined(PYBIND11_NOINLINE_DISABLED) // Option for maximum portability and experimentation.
182 # define PYBIND11_NOINLINE inline
183 #elif defined(_MSC_VER)
184 # define PYBIND11_NOINLINE __declspec(noinline) inline
185 #else
186 # define PYBIND11_NOINLINE __attribute__((noinline)) inline
187 #endif
188 
189 #if defined(__MINGW32__)
190 // For unknown reasons all PYBIND11_DEPRECATED member trigger a warning when declared
191 // whether it is used or not
192 # define PYBIND11_DEPRECATED(reason)
193 #elif defined(PYBIND11_CPP14)
194 # define PYBIND11_DEPRECATED(reason) [[deprecated(reason)]]
195 #else
196 # define PYBIND11_DEPRECATED(reason) __attribute__((deprecated(reason)))
197 #endif
198 
199 #if defined(PYBIND11_CPP17)
200 # define PYBIND11_MAYBE_UNUSED [[maybe_unused]]
201 #elif defined(_MSC_VER) && !defined(__clang__)
202 # define PYBIND11_MAYBE_UNUSED
203 #else
204 # define PYBIND11_MAYBE_UNUSED __attribute__((__unused__))
205 #endif
206 
207 /* Don't let Python.h #define (v)snprintf as macro because they are implemented
208  properly in Visual Studio since 2015. */
209 #if defined(_MSC_VER)
210 # define HAVE_SNPRINTF 1
211 #endif
212 
214 #if defined(_MSC_VER)
215 PYBIND11_WARNING_PUSH
217 // C4505: 'PySlice_GetIndicesEx': unreferenced local function has been removed (PyPy only)
218 # if defined(_DEBUG) && !defined(Py_DEBUG)
219 // Workaround for a VS 2022 issue.
220 // NOTE: This workaround knowingly violates the Python.h include order requirement:
221 // https://docs.python.org/3/c-api/intro.html#include-files
222 // See https://github.com/pybind/pybind11/pull/3497 for full context.
223 # include <yvals.h>
224 # if _MSVC_STL_VERSION >= 143
225 # include <crtdefs.h>
226 # endif
227 # define PYBIND11_DEBUG_MARKER
228 # undef _DEBUG
229 # endif
230 #endif
231 
232 // https://en.cppreference.com/w/c/chrono/localtime
233 #if defined(__STDC_LIB_EXT1__) && !defined(__STDC_WANT_LIB_EXT1__)
234 # define __STDC_WANT_LIB_EXT1__
235 #endif
236 
237 #ifdef __has_include
238 // std::optional (but including it in c++14 mode isn't allowed)
239 # if defined(PYBIND11_CPP17) && __has_include(<optional>)
240 # define PYBIND11_HAS_OPTIONAL 1
241 # endif
242 // std::experimental::optional (but not allowed in c++11 mode)
243 # if defined(PYBIND11_CPP14) && (__has_include(<experimental/optional>) && \
244  !__has_include(<optional>))
245 # define PYBIND11_HAS_EXP_OPTIONAL 1
246 # endif
247 // std::variant
248 # if defined(PYBIND11_CPP17) && __has_include(<variant>)
249 # define PYBIND11_HAS_VARIANT 1
250 # endif
251 #elif defined(_MSC_VER) && defined(PYBIND11_CPP17)
252 # define PYBIND11_HAS_OPTIONAL 1
253 # define PYBIND11_HAS_VARIANT 1
254 #endif
255 
256 #if defined(PYBIND11_CPP17)
257 # if defined(__has_include)
258 # if __has_include(<string_view>)
259 # define PYBIND11_HAS_STRING_VIEW
260 # endif
261 # elif defined(_MSC_VER)
262 # define PYBIND11_HAS_STRING_VIEW
263 # endif
264 #endif
265 
266 #include <Python.h>
267 // Reminder: WITH_THREAD is always defined if PY_VERSION_HEX >= 0x03070000
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."
270 #endif
271 #include <frameobject.h>
272 #include <pythread.h>
273 
274 /* Python #defines overrides on all sorts of core functions, which
275  tends to weak havok in C++ codebases that expect these to work
276  like regular functions (potentially with several overloads) */
277 #if defined(isalnum)
278 # undef isalnum
279 # undef isalpha
280 # undef islower
281 # undef isspace
282 # undef isupper
283 # undef tolower
284 # undef toupper
285 #endif
286 
287 #if defined(copysign)
288 # undef copysign
289 #endif
290 
291 #if defined(PYPY_VERSION) && !defined(PYBIND11_SIMPLE_GIL_MANAGEMENT)
292 # define PYBIND11_SIMPLE_GIL_MANAGEMENT
293 #endif
294 
295 #if defined(_MSC_VER)
296 # if defined(PYBIND11_DEBUG_MARKER)
297 # define _DEBUG
298 # undef PYBIND11_DEBUG_MARKER
299 # endif
301 #endif
302 
303 #include <cstddef>
304 #include <cstring>
305 #include <exception>
306 #include <forward_list>
307 #include <memory>
308 #include <stdexcept>
309 #include <string>
310 #include <type_traits>
311 #include <typeindex>
312 #include <unordered_map>
313 #include <unordered_set>
314 #include <vector>
315 #if defined(__has_include)
316 # if __has_include(<version>)
317 # include <version>
318 # endif
319 #endif
320 
321 // Must be after including <version> or one of the other headers specified by the standard
322 #if defined(__cpp_lib_char8_t) && __cpp_lib_char8_t >= 201811L
323 # define PYBIND11_HAS_U8STRING
324 #endif
325 
326 // See description of PR #4246:
327 #if !defined(PYBIND11_NO_ASSERT_GIL_HELD_INCREF_DECREF) && !defined(NDEBUG) \
328  && !defined(PYPY_VERSION) && !defined(PYBIND11_ASSERT_GIL_HELD_INCREF_DECREF)
329 # define PYBIND11_ASSERT_GIL_HELD_INCREF_DECREF
330 #endif
331 
332 // #define PYBIND11_STR_LEGACY_PERMISSIVE
333 // If DEFINED, pybind11::str can hold PyUnicodeObject or PyBytesObject
334 // (probably surprising and never documented, but this was the
335 // legacy behavior until and including v2.6.x). As a side-effect,
336 // pybind11::isinstance<str>() is true for both pybind11::str and
337 // pybind11::bytes.
338 // If UNDEFINED, pybind11::str can only hold PyUnicodeObject, and
339 // pybind11::isinstance<str>() is true only for pybind11::str.
340 // However, for Python 2 only (!), the pybind11::str caster
341 // implicitly decoded bytes to PyUnicodeObject. This was to ease
342 // the transition from the legacy behavior to the non-permissive
343 // behavior.
344 
346 #define PYBIND11_INSTANCE_METHOD_NEW(ptr, class_) PyInstanceMethod_New(ptr)
347 #define PYBIND11_INSTANCE_METHOD_CHECK PyInstanceMethod_Check
348 #define PYBIND11_INSTANCE_METHOD_GET_FUNCTION PyInstanceMethod_GET_FUNCTION
349 #define PYBIND11_BYTES_CHECK PyBytes_Check
350 #define PYBIND11_BYTES_FROM_STRING PyBytes_FromString
351 #define PYBIND11_BYTES_FROM_STRING_AND_SIZE PyBytes_FromStringAndSize
352 #define PYBIND11_BYTES_AS_STRING_AND_SIZE PyBytes_AsStringAndSize
353 #define PYBIND11_BYTES_AS_STRING PyBytes_AsString
354 #define PYBIND11_BYTES_SIZE PyBytes_Size
355 #define PYBIND11_LONG_CHECK(o) PyLong_Check(o)
356 #define PYBIND11_LONG_AS_LONGLONG(o) PyLong_AsLongLong(o)
357 #define PYBIND11_LONG_FROM_SIGNED(o) PyLong_FromSsize_t((ssize_t) (o))
358 #define PYBIND11_LONG_FROM_UNSIGNED(o) PyLong_FromSize_t((size_t) (o))
359 #define PYBIND11_BYTES_NAME "bytes"
360 #define PYBIND11_STRING_NAME "str"
361 #define PYBIND11_SLICE_OBJECT PyObject
362 #define PYBIND11_FROM_STRING PyUnicode_FromString
363 #define PYBIND11_STR_TYPE ::pybind11::str
364 #define PYBIND11_BOOL_ATTR "__bool__"
365 #define PYBIND11_NB_BOOL(ptr) ((ptr)->nb_bool)
366 #define PYBIND11_BUILTINS_MODULE "builtins"
367 // Providing a separate declaration to make Clang's -Wmissing-prototypes happy.
368 // See comment for PYBIND11_MODULE below for why this is marked "maybe unused".
369 #define PYBIND11_PLUGIN_IMPL(name) \
370  extern "C" PYBIND11_MAYBE_UNUSED PYBIND11_EXPORT PyObject *PyInit_##name(); \
371  extern "C" PYBIND11_EXPORT PyObject *PyInit_##name()
372 
373 #define PYBIND11_TRY_NEXT_OVERLOAD ((PyObject *) 1) // special failure return code
374 #define PYBIND11_STRINGIFY(x) #x
375 #define PYBIND11_TOSTRING(x) PYBIND11_STRINGIFY(x)
376 #define PYBIND11_CONCAT(first, second) first##second
377 #define PYBIND11_ENSURE_INTERNALS_READY pybind11::detail::get_internals();
378 
379 #define PYBIND11_CHECK_PYTHON_VERSION \
380  { \
381  const char *compiled_ver \
382  = PYBIND11_TOSTRING(PY_MAJOR_VERSION) "." PYBIND11_TOSTRING(PY_MINOR_VERSION); \
383  const char *runtime_ver = Py_GetVersion(); \
384  size_t len = std::strlen(compiled_ver); \
385  if (std::strncmp(runtime_ver, compiled_ver, len) != 0 \
386  || (runtime_ver[len] >= '0' && runtime_ver[len] <= '9')) { \
387  PyErr_Format(PyExc_ImportError, \
388  "Python version mismatch: module was compiled for Python %s, " \
389  "but the interpreter version is incompatible: %s.", \
390  compiled_ver, \
391  runtime_ver); \
392  return nullptr; \
393  } \
394  }
395 
396 #define PYBIND11_CATCH_INIT_EXCEPTIONS \
397  catch (pybind11::error_already_set & e) { \
398  pybind11::raise_from(e, PyExc_ImportError, "initialization failed"); \
399  return nullptr; \
400  } \
401  catch (const std::exception &e) { \
402  PyErr_SetString(PyExc_ImportError, e.what()); \
403  return nullptr; \
404  }
405 
418 
421 #define PYBIND11_PLUGIN(name) \
422  PYBIND11_DEPRECATED("PYBIND11_PLUGIN is deprecated, use PYBIND11_MODULE") \
423  static PyObject *pybind11_init(); \
424  PYBIND11_PLUGIN_IMPL(name) { \
425  PYBIND11_CHECK_PYTHON_VERSION \
426  PYBIND11_ENSURE_INTERNALS_READY \
427  try { \
428  return pybind11_init(); \
429  } \
430  PYBIND11_CATCH_INIT_EXCEPTIONS \
431  } \
432  PyObject *pybind11_init()
433 
455 #define PYBIND11_MODULE(name, variable) \
456  static ::pybind11::module_::module_def PYBIND11_CONCAT(pybind11_module_def_, name) \
457  PYBIND11_MAYBE_UNUSED; \
458  PYBIND11_MAYBE_UNUSED \
459  static void PYBIND11_CONCAT(pybind11_init_, name)(::pybind11::module_ &); \
460  PYBIND11_PLUGIN_IMPL(name) { \
461  PYBIND11_CHECK_PYTHON_VERSION \
462  PYBIND11_ENSURE_INTERNALS_READY \
463  auto m = ::pybind11::module_::create_extension_module( \
464  PYBIND11_TOSTRING(name), nullptr, &PYBIND11_CONCAT(pybind11_module_def_, name)); \
465  try { \
466  PYBIND11_CONCAT(pybind11_init_, name)(m); \
467  return m.ptr(); \
468  } \
469  PYBIND11_CATCH_INIT_EXCEPTIONS \
470  } \
471  void PYBIND11_CONCAT(pybind11_init_, name)(::pybind11::module_ & (variable))
472 
474 
475 using ssize_t = Py_ssize_t;
476 using size_t = std::size_t;
477 
478 template <typename IntType>
479 inline ssize_t ssize_t_cast(const IntType &val) {
480  static_assert(sizeof(IntType) <= sizeof(ssize_t), "Implicit narrowing is not permitted.");
481  return static_cast<ssize_t>(val);
482 }
483 
491  automatic = 0,
492 
498 
504 
508  copy,
509 
514  move,
515 
521  reference,
522 
534 };
535 
537 
538 inline static constexpr int log2(size_t n, int k = 0) {
539  return (n <= 1) ? k : log2(n >> 1, k + 1);
540 }
541 
542 // Returns the size as a multiple of sizeof(void *), rounded up.
543 inline static constexpr size_t size_in_ptrs(size_t s) {
544  return 1 + ((s - 1) >> log2(sizeof(void *)));
545 }
546 
553 constexpr size_t instance_simple_holder_in_ptrs() {
554  static_assert(sizeof(std::shared_ptr<int>) >= sizeof(std::unique_ptr<int>),
555  "pybind assumes std::shared_ptrs are at least as big as std::unique_ptrs");
556  return size_in_ptrs(sizeof(std::shared_ptr<int>));
557 }
558 
559 // Forward declarations
560 struct type_info;
561 struct value_and_holder;
562 
566 };
567 
569 struct instance {
570  PyObject_HEAD
572  union {
575  };
577  PyObject *weakrefs;
579  bool owned : 1;
603  bool simple_layout : 1;
609  bool has_patients : 1;
610 
613  void allocate_layout();
614 
616  void deallocate_layout();
617 
621  value_and_holder get_value_and_holder(const type_info *find_type = nullptr,
622  bool throw_if_missing = true);
623 
625  static constexpr uint8_t status_holder_constructed = 1;
626  static constexpr uint8_t status_instance_registered = 2;
627 };
628 
630  "Internal error: `pybind11::detail::instance` is not standard layout!");
631 
633 #if defined(PYBIND11_CPP14)
634 using std::conditional_t;
635 using std::enable_if_t;
636 using std::remove_cv_t;
638 #else
639 template <bool B, typename T = void>
641 template <bool B, typename T, typename F>
643 template <typename T>
645 template <typename T>
647 #endif
648 
649 #if defined(PYBIND11_CPP20)
650 using std::remove_cvref;
651 using std::remove_cvref_t;
652 #else
653 template <class T>
654 struct remove_cvref {
656 };
657 template <class T>
659 #endif
660 
662 template <typename T, typename U>
663 using is_same_ignoring_cvref = std::is_same<detail::remove_cvref_t<T>, U>;
664 
666 #if defined(PYBIND11_CPP14)
667 using std::index_sequence;
669 #else
670 template <size_t...>
671 struct index_sequence {};
672 template <size_t N, size_t... S>
673 struct make_index_sequence_impl : make_index_sequence_impl<N - 1, N - 1, S...> {};
674 template <size_t... S>
676  using type = index_sequence<S...>;
677 };
678 template <size_t N>
680 #endif
681 
683 template <typename ISeq, size_t, bool...>
685  using type = ISeq;
686 };
687 template <size_t... IPrev, size_t I, bool B, bool... Bs>
688 struct select_indices_impl<index_sequence<IPrev...>, I, B, Bs...>
689  : select_indices_impl<conditional_t<B, index_sequence<IPrev..., I>, index_sequence<IPrev...>>,
690  I + 1,
691  Bs...> {};
692 template <bool... Bs>
694 
696 template <bool B>
697 using bool_constant = std::integral_constant<bool, B>;
698 template <typename T>
699 struct negation : bool_constant<!T::value> {};
700 
701 // PGI/Intel cannot detect operator delete with the "compatible" void_t impl, so
702 // using the new one (C++14 defect, so generally works on newer compilers, even
703 // if not in C++17 mode)
704 #if defined(__PGIC__) || defined(__INTEL_COMPILER)
705 template <typename...>
706 using void_t = void;
707 #else
708 template <typename...>
709 struct void_t_impl {
710  using type = void;
711 };
712 template <typename... Ts>
713 using void_t = typename void_t_impl<Ts...>::type;
714 #endif
715 
717 #if defined(__cpp_fold_expressions) && !(defined(_MSC_VER) && (_MSC_VER < 1916))
718 template <class... Ts>
719 using all_of = bool_constant<(Ts::value && ...)>;
720 template <class... Ts>
721 using any_of = bool_constant<(Ts::value || ...)>;
722 #elif !defined(_MSC_VER)
723 template <bool...>
724 struct bools {};
725 template <class... Ts>
726 using all_of = std::is_same<bools<Ts::value..., true>, bools<true, Ts::value...>>;
727 template <class... Ts>
729 #else
730 // MSVC has trouble with the above, but supports std::conjunction, which we can use instead (albeit
731 // at a slight loss of compilation efficiency).
732 template <class... Ts>
733 using all_of = std::conjunction<Ts...>;
734 template <class... Ts>
735 using any_of = std::disjunction<Ts...>;
736 #endif
737 template <class... Ts>
738 using none_of = negation<any_of<Ts...>>;
739 
740 template <class T, template <class> class... Predicates>
742 template <class T, template <class> class... Predicates>
744 template <class T, template <class> class... Predicates>
746 
748 template <typename T>
749 struct remove_class {};
750 template <typename C, typename R, typename... A>
751 struct remove_class<R (C::*)(A...)> {
752  using type = R(A...);
753 };
754 template <typename C, typename R, typename... A>
755 struct remove_class<R (C::*)(A...) const> {
756  using type = R(A...);
757 };
758 #ifdef __cpp_noexcept_function_type
759 template <typename C, typename R, typename... A>
760 struct remove_class<R (C::*)(A...) noexcept> {
761  using type = R(A...);
762 };
763 template <typename C, typename R, typename... A>
764 struct remove_class<R (C::*)(A...) const noexcept> {
765  using type = R(A...);
766 };
767 #endif
768 template <typename T>
771  using type = T;
772 };
773 template <typename T>
774 struct intrinsic_type<const T> {
775  using type = typename intrinsic_type<T>::type;
776 };
777 template <typename T>
778 struct intrinsic_type<T *> {
779  using type = typename intrinsic_type<T>::type;
780 };
781 template <typename T>
782 struct intrinsic_type<T &> {
783  using type = typename intrinsic_type<T>::type;
784 };
785 template <typename T>
786 struct intrinsic_type<T &&> {
787  using type = typename intrinsic_type<T>::type;
788 };
789 template <typename T, size_t N>
790 struct intrinsic_type<const T[N]> {
791  using type = typename intrinsic_type<T>::type;
792 };
793 template <typename T, size_t N>
794 struct intrinsic_type<T[N]> {
795  using type = typename intrinsic_type<T>::type;
796 };
797 template <typename T>
799 
801 struct void_type {};
802 
804 template <typename...>
805 struct type_list {};
806 
808 #ifdef __cpp_fold_expressions
809 template <typename... Ts>
810 constexpr size_t constexpr_sum(Ts... ns) {
811  return (0 + ... + size_t{ns});
812 }
813 #else
814 constexpr size_t constexpr_sum() { return 0; }
815 template <typename T, typename... Ts>
816 constexpr size_t constexpr_sum(T n, Ts... ns) {
817  return size_t{n} + constexpr_sum(ns...);
818 }
819 #endif
820 
821 PYBIND11_NAMESPACE_BEGIN(constexpr_impl)
823 constexpr int first(int i) { return i; }
824 template <typename T, typename... Ts>
825 constexpr int first(int i, T v, Ts... vs) {
826  return v ? i : first(i + 1, vs...);
827 }
828 
829 constexpr int last(int /*i*/, int result) { return result; }
830 template <typename T, typename... Ts>
831 constexpr int last(int i, int result, T v, Ts... vs) {
832  return last(i + 1, v ? i : result, vs...);
833 }
834 PYBIND11_NAMESPACE_END(constexpr_impl)
835 
836 template <template <typename> class Predicate, typename... Ts>
839 constexpr int constexpr_first() {
841 }
842 
844 template <template <typename> class Predicate, typename... Ts>
845 constexpr int constexpr_last() {
846  return constexpr_impl::last(0, -1, Predicate<Ts>::value...);
847 }
848 
850 template <size_t N, typename T, typename... Ts>
851 struct pack_element {
852  using type = typename pack_element<N - 1, Ts...>::type;
853 };
854 template <typename T, typename... Ts>
855 struct pack_element<0, T, Ts...> {
856  using type = T;
857 };
858 
861 template <template <typename> class Predicate, typename Default, typename... Ts>
862 struct exactly_one {
863  static constexpr auto found = constexpr_sum(Predicate<Ts>::value...);
864  static_assert(found <= 1, "Found more than one type matching the predicate");
865 
866  static constexpr auto index = found ? constexpr_first<Predicate, Ts...>() : 0;
868 };
869 template <template <typename> class P, typename Default>
871  using type = Default;
872 };
873 
874 template <template <typename> class Predicate, typename Default, typename... Ts>
875 using exactly_one_t = typename exactly_one<Predicate, Default, Ts...>::type;
876 
878 template <typename T, typename... /*Us*/>
880  using type = T;
881 };
882 template <typename T, typename... Us>
883 using deferred_t = typename deferred_type<T, Us...>::type;
884 
887 template <typename Base, typename Derived>
888 using is_strict_base_of
890 
894 template <typename Base, typename Derived>
898 
899 template <template <typename...> class Base>
901  template <typename... Us>
902  static std::true_type check(Base<Us...> *);
903  static std::false_type check(...);
904 };
905 
908 template <template <typename...> class Base, typename T>
909 // Sadly, all MSVC versions incl. 2022 need the workaround, even in C++20 mode.
910 // See also: https://github.com/pybind/pybind11/pull/3741
911 #if !defined(_MSC_VER)
914 #else
915 struct is_template_base_of
916  : decltype(is_template_base_of_impl<Base>::check((intrinsic_t<T> *) nullptr)) {
917 };
918 #endif
919 
922 template <template <typename...> class Class, typename T>
923 struct is_instantiation : std::false_type {};
924 template <template <typename...> class Class, typename... Us>
925 struct is_instantiation<Class, Class<Us...>> : std::true_type {};
926 
928 template <typename T>
930 
932 template <typename T, typename = void>
933 struct is_input_iterator : std::false_type {};
934 template <typename T>
936  void_t<decltype(*std::declval<T &>()), decltype(++std::declval<T &>())>>
937  : std::true_type {};
938 
939 template <typename T>
943 
944 template <typename F>
946  // If you are encountering an
947  // 'error: name followed by "::" must be a class or namespace name'
948  // with the Intel compiler and a noexcept function here,
949  // try to use noexcept(true) instead of plain noexcept.
950  using type = typename remove_class<decltype(&F::operator())>::type;
951 };
952 
953 // Extracts the function signature from a function, function pointer or lambda.
954 template <typename Function, typename F = remove_reference_t<Function>>
957  F,
959  std::remove_pointer<F>,
961 
965 template <typename T>
967  std::is_function,
968  std::is_pointer,
969  std::is_member_pointer>;
970 
971 // [workaround(intel)] Internal error on fold expression
973 #if defined(__cpp_fold_expressions) && !defined(__INTEL_COMPILER)
974 // Intel compiler produces an internal error on this fold expression (tested with ICC 19.0.2)
975 # define PYBIND11_EXPAND_SIDE_EFFECTS(PATTERN) (((PATTERN), void()), ...)
976 #else
977 using expand_side_effects = bool[];
978 # define PYBIND11_EXPAND_SIDE_EFFECTS(PATTERN) \
979  (void) pybind11::detail::expand_side_effects { ((PATTERN), void(), false)..., false }
980 #endif
981 
983 
984 class PYBIND11_EXPORT_EXCEPTION builtin_exception : public std::runtime_error {
986 public:
987  using std::runtime_error::runtime_error;
989  virtual void set_error() const = 0;
990 };
991 
992 #define PYBIND11_RUNTIME_EXCEPTION(name, type) \
993  class PYBIND11_EXPORT_EXCEPTION name : public builtin_exception { \
994  public: \
995  using builtin_exception::builtin_exception; \
996  name() : name("") {} \
997  void set_error() const override { PyErr_SetString(type, what()); } \
998  };
999 
1000 PYBIND11_RUNTIME_EXCEPTION(stop_iteration, PyExc_StopIteration)
1001 PYBIND11_RUNTIME_EXCEPTION(index_error, PyExc_IndexError)
1002 PYBIND11_RUNTIME_EXCEPTION(key_error, PyExc_KeyError)
1003 PYBIND11_RUNTIME_EXCEPTION(value_error, PyExc_ValueError)
1004 PYBIND11_RUNTIME_EXCEPTION(type_error, PyExc_TypeError)
1005 PYBIND11_RUNTIME_EXCEPTION(buffer_error, PyExc_BufferError)
1006 PYBIND11_RUNTIME_EXCEPTION(import_error, PyExc_ImportError)
1007 PYBIND11_RUNTIME_EXCEPTION(attribute_error, PyExc_AttributeError)
1008 PYBIND11_RUNTIME_EXCEPTION(cast_error, PyExc_RuntimeError)
1009 PYBIND11_RUNTIME_EXCEPTION(reference_cast_error, PyExc_RuntimeError)
1012 
1013 [[noreturn]] PYBIND11_NOINLINE void pybind11_fail(const char *reason) {
1014  assert(!PyErr_Occurred());
1015  throw std::runtime_error(reason);
1016 }
1017 [[noreturn]] PYBIND11_NOINLINE void pybind11_fail(const std::string &reason) {
1018  assert(!PyErr_Occurred());
1019  throw std::runtime_error(reason);
1020 }
1021 
1022 template <typename T, typename SFINAE = void>
1024 
1025 template <typename T>
1027  T,
1028  detail::enable_if_t<detail::is_same_ignoring_cvref<T, PyObject *>::value>> {
1029  static constexpr const char c = 'O';
1030  static constexpr const char value[2] = {c, '\0'};
1031  static std::string format() { return std::string(1, c); }
1032 };
1033 
1035 // Returns the index of the given type in the type char array below, and in the list in numpy.h
1036 // The order here is: bool; 8 ints ((signed,unsigned)x(8,16,32,64)bits); float,double,long double;
1037 // complex float,double,long double. Note that the long double types only participate when long
1038 // double is actually longer than double (it isn't under MSVC).
1039 // NB: not only the string below but also complex.h and numpy.h rely on this order.
1040 template <typename T, typename SFINAE = void>
1042  static constexpr bool value = false;
1043 };
1044 template <typename T>
1045 struct is_fmt_numeric<T, enable_if_t<std::is_arithmetic<T>::value>> {
1046  static constexpr bool value = true;
1047  static constexpr int index
1049  ? 0
1050  : 1
1052  ? detail::log2(sizeof(T)) * 2 + std::is_unsigned<T>::value
1053  : 8
1056  : 0));
1057 };
1059 
1060 template <typename T>
1061 struct format_descriptor<T, detail::enable_if_t<std::is_arithmetic<T>::value>> {
1062  static constexpr const char c = "?bBhHiIqQfdg"[detail::is_fmt_numeric<T>::index];
1063  static constexpr const char value[2] = {c, '\0'};
1064  static std::string format() { return std::string(1, c); }
1065 };
1066 
1067 #if !defined(PYBIND11_CPP17)
1068 
1069 template <typename T>
1070 constexpr const char
1072 
1073 #endif
1074 
1076 struct error_scope {
1077  PyObject *type, *value, *trace;
1078  error_scope() { PyErr_Fetch(&type, &value, &trace); }
1079  error_scope(const error_scope &) = delete;
1080  error_scope &operator=(const error_scope &) = delete;
1081  ~error_scope() { PyErr_Restore(type, value, trace); }
1082 };
1083 
1085 struct nodelete {
1086  template <typename T>
1087  void operator()(T *) {}
1088 };
1089 
1091 template <typename... Args>
1093  template <typename Return>
1094  constexpr auto operator()(Return (*pf)(Args...)) const noexcept -> decltype(pf) {
1095  return pf;
1096  }
1097 
1098  template <typename Return, typename Class>
1099  constexpr auto operator()(Return (Class::*pmf)(Args...), std::false_type = {}) const noexcept
1100  -> decltype(pmf) {
1101  return pmf;
1102  }
1103 
1104  template <typename Return, typename Class>
1105  constexpr auto operator()(Return (Class::*pmf)(Args...) const, std::true_type) const noexcept
1106  -> decltype(pmf) {
1107  return pmf;
1108  }
1109 };
1111 
1112 // overload_cast requires variable templates: C++14
1113 #if defined(PYBIND11_CPP14)
1114 # define PYBIND11_OVERLOAD_CAST 1
1115 template <typename... Args>
1119 static constexpr detail::overload_cast_impl<Args...> overload_cast{};
1120 #endif
1121 
1125 static constexpr auto const_ = std::true_type{};
1126 
1127 #if !defined(PYBIND11_CPP14) // no overload_cast: providing something that static_assert-fails:
1128 template <typename... Args>
1131  "pybind11::overload_cast<...> requires compiling in C++14 mode");
1132 };
1133 #endif // overload_cast
1134 
1136 
1137 // Adaptor for converting arbitrary container arguments into a vector; implicitly convertible from
1138 // any standard container (or C-style array) supporting std::begin/std::end, any singleton
1139 // arithmetic type (if T is arithmetic), or explicitly constructible from an iterator pair.
1140 template <typename T>
1142  std::vector<T> v;
1143 
1144 public:
1145  any_container() = default;
1146 
1147  // Can construct from a pair of iterators
1150 
1151  // Implicit conversion constructor from any arbitrary container type
1152  // with values convertible to T
1153  template <typename Container,
1154  typename = enable_if_t<
1155  std::is_convertible<decltype(*std::begin(std::declval<const Container &>())),
1156  T>::value>>
1157  // NOLINTNEXTLINE(google-explicit-constructor)
1158  any_container(const Container &c) : any_container(std::begin(c), std::end(c)) {}
1159 
1160  // initializer_list's aren't deducible, so don't get matched by the above template;
1161  // we need this to explicitly allow implicit conversion from one:
1163  any_container(const std::initializer_list<TIn> &c) : any_container(c.begin(), c.end()) {}
1164 
1165  // Avoid copying if given an rvalue vector of the correct type.
1166  // NOLINTNEXTLINE(google-explicit-constructor)
1167  any_container(std::vector<T> &&v) : v(std::move(v)) {}
1168 
1169  // Moves the vector out of an rvalue any_container
1170  // NOLINTNEXTLINE(google-explicit-constructor)
1171  operator std::vector<T> &&() && { return std::move(v); }
1172 
1173  // Dereferencing obtains a reference to the underlying vector
1174  std::vector<T> &operator*() { return v; }
1175  const std::vector<T> &operator*() const { return v; }
1176 
1177  // -> lets you call methods on the underlying vector
1178  std::vector<T> *operator->() { return &v; }
1179  const std::vector<T> *operator->() const { return &v; }
1180 };
1181 
1182 // Forward-declaration; see detail/class.h
1183 std::string get_fully_qualified_tp_name(PyTypeObject *);
1184 
1185 template <typename T>
1186 inline static std::shared_ptr<T>
1187 try_get_shared_from_this(std::enable_shared_from_this<T> *holder_value_ptr) {
1188 // Pre C++17, this code path exploits undefined behavior, but is known to work on many platforms.
1189 // Use at your own risk!
1190 // See also https://en.cppreference.com/w/cpp/memory/enable_shared_from_this, and in particular
1191 // the `std::shared_ptr<Good> gp1 = not_so_good.getptr();` and `try`-`catch` parts of the example.
1192 #if defined(__cpp_lib_enable_shared_from_this) && (!defined(_MSC_VER) || _MSC_VER >= 1912)
1193  return holder_value_ptr->weak_from_this().lock();
1194 #else
1195  try {
1196  return holder_value_ptr->shared_from_this();
1197  } catch (const std::bad_weak_ptr &) {
1198  return nullptr;
1199  }
1200 #endif
1201 }
1202 
1203 // For silencing "unused" compiler warnings in special situations.
1204 template <typename... Args>
1205 #if defined(_MSC_VER) && _MSC_VER < 1920 // MSVC 2017
1206 constexpr
1207 #endif
1208  inline void
1210 }
1211 
1212 // MSVC warning C4100: Unreferenced formal parameter
1213 #if defined(_MSC_VER) && _MSC_VER <= 1916
1214 # define PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(...) \
1215  detail::silence_unused_warnings(__VA_ARGS__)
1216 #else
1217 # define PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(...)
1218 #endif
1219 
1220 // GCC -Wunused-but-set-parameter All GCC versions (as of July 2021).
1221 #if defined(__GNUG__) && !defined(__clang__) && !defined(__INTEL_COMPILER)
1222 # define PYBIND11_WORKAROUND_INCORRECT_GCC_UNUSED_BUT_SET_PARAMETER(...) \
1223  detail::silence_unused_warnings(__VA_ARGS__)
1224 #else
1225 # define PYBIND11_WORKAROUND_INCORRECT_GCC_UNUSED_BUT_SET_PARAMETER(...)
1226 #endif
1227 
1228 #if defined(__clang__) \
1229  && (defined(__apple_build_version__) /* AppleClang 13.0.0.13000029 was the only data point \
1230  available. */ \
1231  || (__clang_major__ >= 7 \
1232  && __clang_major__ <= 12) /* Clang 3, 5, 13, 14, 15 do not generate the warning. */ \
1233  )
1234 # define PYBIND11_DETECTED_CLANG_WITH_MISLEADING_CALL_STD_MOVE_EXPLICITLY_WARNING
1235 // Example:
1236 // tests/test_kwargs_and_defaults.cpp:46:68: error: local variable 'args' will be copied despite
1237 // being returned by name [-Werror,-Wreturn-std-move]
1238 // m.def("args_function", [](py::args args) -> py::tuple { return args; });
1239 // ^~~~
1240 // test_kwargs_and_defaults.cpp:46:68: note: call 'std::move' explicitly to avoid copying
1241 // m.def("args_function", [](py::args args) -> py::tuple { return args; });
1242 // ^~~~
1243 // std::move(args)
1244 #endif
1245 
1246 // Pybind offers detailed error messages by default for all builts that are debug (through the
1247 // negation of NDEBUG). This can also be manually enabled by users, for any builds, through
1248 // defining PYBIND11_DETAILED_ERROR_MESSAGES. This information is primarily useful for those
1249 // who are writing (as opposed to merely using) libraries that use pybind11.
1250 #if !defined(PYBIND11_DETAILED_ERROR_MESSAGES) && !defined(NDEBUG)
1251 # define PYBIND11_DETAILED_ERROR_MESSAGES
1252 #endif
1253 
select_indices
typename select_indices_impl< index_sequence<>, 0, Bs... >::type select_indices
Definition: wrap/pybind11/include/pybind11/detail/common.h:693
return_value_policy::reference_internal
@ reference_internal
format_descriptor
Definition: wrap/pybind11/include/pybind11/detail/common.h:1023
nonsimple_values_and_holders
Definition: wrap/pybind11/include/pybind11/detail/common.h:563
return_value_policy::move
@ move
all_of
std::is_same< bools< Ts::value..., true >, bools< true, Ts::value... > > all_of
Definition: wrap/pybind11/include/pybind11/detail/common.h:726
error_scope
RAII wrapper that temporarily clears any Python error state.
Definition: wrap/pybind11/include/pybind11/detail/common.h:1076
expand_side_effects
bool[] expand_side_effects
Apply a function over each element of a parameter pack.
Definition: wrap/pybind11/include/pybind11/detail/common.h:977
pack_element
Return the Nth element from the parameter pack.
Definition: wrap/pybind11/include/pybind11/detail/common.h:851
is_instantiation
Definition: wrap/pybind11/include/pybind11/detail/common.h:923
B
Matrix< SCALARB, Dynamic, Dynamic, opt_B > B
Definition: bench_gemm.cpp:49
is_fmt_numeric
Definition: wrap/pybind11/include/pybind11/detail/common.h:1041
is_function_pointer
bool_constant< std::is_pointer< T >::value &&std::is_function< typename std::remove_pointer< T >::type >::value > is_function_pointer
Definition: wrap/pybind11/include/pybind11/detail/common.h:942
error_scope::operator=
error_scope & operator=(const error_scope &)=delete
strip_function_object::type
typename remove_class< decltype(&F::operator())>::type type
Definition: wrap/pybind11/include/pybind11/detail/common.h:950
intrinsic_type
Helper template to strip away type modifiers.
Definition: wrap/pybind11/include/pybind11/detail/common.h:770
index_sequence
Index sequences.
Definition: wrap/pybind11/include/pybind11/detail/common.h:671
gtsam.examples.DogLegOptimizerExample.type
type
Definition: DogLegOptimizerExample.py:111
ssize_t
Py_ssize_t ssize_t
Definition: wrap/pybind11/include/pybind11/detail/common.h:475
instance::simple_layout
bool simple_layout
Definition: wrap/pybind11/include/pybind11/detail/common.h:603
type_info
Definition: internals.h:226
instance_simple_holder_in_ptrs
constexpr size_t instance_simple_holder_in_ptrs()
Definition: wrap/pybind11/include/pybind11/detail/common.h:553
s
RealScalar s
Definition: level1_cplx_impl.h:126
instance::nonsimple
nonsimple_values_and_holders nonsimple
Definition: wrap/pybind11/include/pybind11/detail/common.h:574
return_value_policy
return_value_policy
Approach used to cast a previously unknown C++ instance into a Python object.
Definition: wrap/pybind11/include/pybind11/detail/common.h:485
exactly_one::found
static constexpr auto found
Definition: wrap/pybind11/include/pybind11/detail/common.h:863
any_container::operator->
const std::vector< T > * operator->() const
Definition: wrap/pybind11/include/pybind11/detail/common.h:1179
instance::get_value_and_holder
value_and_holder get_value_and_holder(const type_info *find_type=nullptr, bool throw_if_missing=true)
Definition: type_caster_base.h:380
void_t
typename void_t_impl< Ts... >::type void_t
Definition: wrap/pybind11/include/pybind11/detail/common.h:713
is_template_base_of_impl
Definition: wrap/pybind11/include/pybind11/detail/common.h:900
c
Scalar Scalar * c
Definition: benchVecAdd.cpp:17
instance::status_instance_registered
static constexpr uint8_t status_instance_registered
Definition: wrap/pybind11/include/pybind11/detail/common.h:626
constexpr_sum
constexpr size_t constexpr_sum()
Compile-time integer sum.
Definition: wrap/pybind11/include/pybind11/detail/common.h:814
exactly_one
Definition: wrap/pybind11/include/pybind11/detail/common.h:862
any_container::any_container
any_container(It first, It last)
Definition: wrap/pybind11/include/pybind11/detail/common.h:1149
error_scope::error_scope
error_scope()
Definition: wrap/pybind11/include/pybind11/detail/common.h:1078
remove_cv_t
typename std::remove_cv< T >::type remove_cv_t
Definition: wrap/pybind11/include/pybind11/detail/common.h:644
deferred_t
typename deferred_type< T, Us... >::type deferred_t
Definition: wrap/pybind11/include/pybind11/detail/common.h:883
const_
static constexpr auto const_
Definition: wrap/pybind11/include/pybind11/detail/common.h:1125
try_get_shared_from_this
static std::shared_ptr< T > try_get_shared_from_this(std::enable_shared_from_this< T > *holder_value_ptr)
Definition: wrap/pybind11/include/pybind11/detail/common.h:1187
error_scope::trace
PyObject * trace
Definition: wrap/pybind11/include/pybind11/detail/common.h:1077
remove_class
Strip the class from a method type.
Definition: wrap/pybind11/include/pybind11/detail/common.h:749
B
Definition: test_numpy_dtypes.cpp:299
PYBIND11_WARNING_POP
PYBIND11_WARNING_PUSH PYBIND11_WARNING_POP
Definition: tensor.h:30
PYBIND11_NAMESPACE_END
#define PYBIND11_NAMESPACE_END(name)
Definition: wrap/pybind11/include/pybind11/detail/common.h:80
make_index_sequence_impl
Definition: wrap/pybind11/include/pybind11/detail/common.h:673
PYBIND11_NOINLINE
#define PYBIND11_NOINLINE
Definition: wrap/pybind11/include/pybind11/detail/common.h:186
is_template_base_of
decltype(is_template_base_of_impl< Base >::check((intrinsic_t< T > *) nullptr)) is_template_base_of
Definition: wrap/pybind11/include/pybind11/detail/common.h:913
type
Definition: pytypes.h:1491
value_and_holder
Definition: type_caster_base.h:253
T
Eigen::Triplet< double > T
Definition: Tutorial_sparse_example.cpp:6
bools
Compile-time all/any/none of that check the boolean value of all template types.
Definition: wrap/pybind11/include/pybind11/detail/common.h:724
detail
Definition: testSerializationNonlinear.cpp:70
format_descriptor< T, detail::enable_if_t< std::is_arithmetic< T >::value > >::format
static std::string format()
Definition: wrap/pybind11/include/pybind11/detail/common.h:1064
nonsimple_values_and_holders::values_and_holders
void ** values_and_holders
Definition: wrap/pybind11/include/pybind11/detail/common.h:564
PYBIND11_NAMESPACE_BEGIN
#define PYBIND11_NAMESPACE_BEGIN(name)
Definition: wrap/pybind11/include/pybind11/detail/common.h:76
any_container::v
std::vector< T > v
Definition: wrap/pybind11/include/pybind11/detail/common.h:1142
size_in_ptrs
static constexpr size_t size_in_ptrs(size_t s)
Definition: wrap/pybind11/include/pybind11/detail/common.h:543
log2
static constexpr int log2(size_t n, int k=0)
Definition: wrap/pybind11/include/pybind11/detail/common.h:538
PYBIND11_WARNING_DISABLE_MSVC
#define PYBIND11_WARNING_DISABLE_MSVC(name)
Definition: wrap/pybind11/include/pybind11/detail/common.h:55
instance::simple_value_holder
void * simple_value_holder[1+instance_simple_holder_in_ptrs()]
Definition: wrap/pybind11/include/pybind11/detail/common.h:573
nonsimple_values_and_holders::status
uint8_t * status
Definition: wrap/pybind11/include/pybind11/detail/common.h:565
result
Values result
Definition: OdometryOptimize.cpp:8
any_container::operator->
std::vector< T > * operator->()
Definition: wrap/pybind11/include/pybind11/detail/common.h:1178
get_fully_qualified_tp_name
std::string get_fully_qualified_tp_name(PyTypeObject *)
Definition: class.h:28
PYBIND11_RUNTIME_EXCEPTION
#define PYBIND11_RUNTIME_EXCEPTION(name, type)
Definition: wrap/pybind11/include/pybind11/detail/common.h:992
remove_cvref
Definition: wrap/pybind11/include/pybind11/detail/common.h:654
uint8_t
unsigned char uint8_t
Definition: ms_stdint.h:83
instance::allocate_layout
void allocate_layout()
Definition: type_caster_base.h:410
conditional_t
typename std::conditional< B, T, F >::type conditional_t
Definition: wrap/pybind11/include/pybind11/detail/common.h:642
type_list
Helper template which holds a list of types.
Definition: wrap/pybind11/include/pybind11/detail/common.h:805
instance
The 'instance' type which needs to be standard layout (need to be able to use 'offsetof')
Definition: wrap/pybind11/include/pybind11/detail/common.h:569
exactly_one::type
conditional_t< found, typename pack_element< index, Ts... >::type, Default > type
Definition: wrap/pybind11/include/pybind11/detail/common.h:867
n
int n
Definition: BiCGSTAB_simple.cpp:1
any_container
Definition: wrap/pybind11/include/pybind11/detail/common.h:1141
satisfies_all_of
all_of< Predicates< T >... > satisfies_all_of
Definition: wrap/pybind11/include/pybind11/detail/common.h:741
is_fmt_numeric::value
static constexpr bool value
Definition: wrap/pybind11/include/pybind11/detail/common.h:1042
any_container::any_container
any_container(const Container &c)
Definition: wrap/pybind11/include/pybind11/detail/common.h:1158
exactly_one_t
typename exactly_one< Predicate, Default, Ts... >::type exactly_one_t
Definition: wrap/pybind11/include/pybind11/detail/common.h:875
A
Definition: test_numpy_dtypes.cpp:298
return_value_policy::automatic
@ automatic
intrinsic_t
typename intrinsic_type< T >::type intrinsic_t
Definition: wrap/pybind11/include/pybind11/detail/common.h:798
I
#define I
Definition: main.h:112
pack_element::type
typename pack_element< N - 1, Ts... >::type type
Definition: wrap/pybind11/include/pybind11/detail/common.h:852
return_value_policy::copy
@ copy
PYBIND11_EXPORT_EXCEPTION
#define PYBIND11_EXPORT_EXCEPTION
Definition: wrap/pybind11/include/pybind11/detail/common.h:163
instance::simple_instance_registered
bool simple_instance_registered
For simple layout, tracks whether the instance is registered in registered_instances
Definition: wrap/pybind11/include/pybind11/detail/common.h:607
instance::deallocate_layout
void deallocate_layout()
Destroys/deallocates all of the above.
Definition: type_caster_base.h:459
first
constexpr int first(int i)
Implementation details for constexpr functions.
Definition: wrap/pybind11/include/pybind11/detail/common.h:823
remove_cvref_t
typename remove_cvref< T >::type remove_cvref_t
Definition: wrap/pybind11/include/pybind11/detail/common.h:658
return_value_policy::reference
@ reference
overload_cast_impl
Definition: wrap/pybind11/include/pybind11/detail/common.h:1092
negation
Definition: wrap/pybind11/include/pybind11/detail/common.h:699
any_container::operator*
std::vector< T > & operator*()
Definition: wrap/pybind11/include/pybind11/detail/common.h:1174
strip_function_object
Definition: wrap/pybind11/include/pybind11/detail/common.h:945
instance::has_patients
bool has_patients
If true, get_internals().patients has an entry for this object.
Definition: wrap/pybind11/include/pybind11/detail/common.h:609
any_container::operator*
const std::vector< T > & operator*() const
Definition: wrap/pybind11/include/pybind11/detail/common.h:1175
exactly_one::index
static constexpr auto index
Definition: wrap/pybind11/include/pybind11/detail/common.h:866
instance::owned
bool owned
If true, the pointer is owned which means we're free to manage it with a holder.
Definition: wrap/pybind11/include/pybind11/detail/common.h:579
PYBIND11_NAMESPACE
Definition: test_custom_type_casters.cpp:24
Eigen::Triplet< double >
test_call_policies.reason
reason
Definition: test_call_policies.py:8
error_scope::value
PyObject * value
Definition: wrap/pybind11/include/pybind11/detail/common.h:1077
instance::status_holder_constructed
static constexpr uint8_t status_holder_constructed
Bit values for the non-simple status flags.
Definition: wrap/pybind11/include/pybind11/detail/common.h:625
pybind11_fail
PyExc_RuntimeError PYBIND11_NOINLINE void pybind11_fail(const char *reason)
Used internally.
Definition: wrap/pybind11/include/pybind11/detail/common.h:1013
gtsam::symbol_shorthand::F
Key F(std::uint64_t j)
Definition: inference/Symbol.h:153
size_t
std::size_t size_t
Definition: wrap/pybind11/include/pybind11/detail/common.h:476
silence_unused_warnings
void silence_unused_warnings(Args &&...)
Definition: wrap/pybind11/include/pybind11/detail/common.h:1209
is_same_ignoring_cvref
std::is_same< detail::remove_cvref_t< T >, U > is_same_ignoring_cvref
Example usage: is_same_ignoring_cvref<T, PyObject *>::value.
Definition: wrap/pybind11/include/pybind11/detail/common.h:663
deferred_type
Defer the evaluation of type T until types Us are instantiated.
Definition: wrap/pybind11/include/pybind11/detail/common.h:879
bool_constant
std::integral_constant< bool, B > bool_constant
Backports of std::bool_constant and std::negation to accommodate older compilers.
Definition: wrap/pybind11/include/pybind11/detail/common.h:697
return_value_policy::take_ownership
@ take_ownership
nodelete::operator()
void operator()(T *)
Definition: wrap/pybind11/include/pybind11/detail/common.h:1087
last
constexpr int last(int, int result)
Definition: wrap/pybind11/include/pybind11/detail/common.h:829
overload_cast_impl::operator()
constexpr auto operator()(Return(*pf)(Args...)) const noexcept -> decltype(pf)
Definition: wrap/pybind11/include/pybind11/detail/common.h:1094
C
Matrix< Scalar, Dynamic, Dynamic > C
Definition: bench_gemm.cpp:50
make_index_sequence
typename make_index_sequence_impl< N >::type make_index_sequence
Definition: wrap/pybind11/include/pybind11/detail/common.h:679
function_signature_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
Definition: wrap/pybind11/include/pybind11/detail/common.h:960
constexpr_last
constexpr int constexpr_last()
Return the index of the last type in Ts which satisfies Predicate<T>, or -1 if none match.
Definition: wrap/pybind11/include/pybind11/detail/common.h:845
is_strict_base_of
bool_constant< std::is_base_of< Base, Derived >::value &&!std::is_same< Base, Derived >::value > is_strict_base_of
Definition: wrap/pybind11/include/pybind11/detail/common.h:889
instance::simple_holder_constructed
bool simple_holder_constructed
For simple layout, tracks whether the holder has been constructed.
Definition: wrap/pybind11/include/pybind11/detail/common.h:605
ssize_t_cast
ssize_t ssize_t_cast(const IntType &val)
Definition: wrap/pybind11/include/pybind11/detail/common.h:479
Class
Definition: testExpression.cpp:116
is_input_iterator
Check if T looks like an input iterator.
Definition: wrap/pybind11/include/pybind11/detail/common.h:933
std
Definition: BFloat16.h:88
void_type
Helper type to replace 'void' in some expressions.
Definition: wrap/pybind11/include/pybind11/detail/common.h:801
any_container::any_container
any_container(const std::initializer_list< TIn > &c)
Definition: wrap/pybind11/include/pybind11/detail/common.h:1163
error_scope::type
PyObject * type
Definition: wrap/pybind11/include/pybind11/detail/common.h:1077
instance::weakrefs
PyObject * weakrefs
Weak references.
Definition: wrap/pybind11/include/pybind11/detail/common.h:577
is_accessible_base_of
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
Definition: wrap/pybind11/include/pybind11/detail/common.h:897
overload_cast_impl::operator()
constexpr auto operator()(Return(Class::*pmf)(Args...), std::false_type={}) const noexcept -> decltype(pmf)
Definition: wrap/pybind11/include/pybind11/detail/common.h:1099
void_t_impl
Definition: wrap/pybind11/include/pybind11/detail/common.h:709
v
Array< int, Dynamic, 1 > v
Definition: Array_initializer_list_vector_cxx11.cpp:1
P
static double P[]
Definition: ellpe.c:68
Eigen::Default
@ Default
Definition: Constants.h:362
U
@ U
Definition: testDecisionTree.cpp:296
nodelete
Dummy destructor wrapper that can be used to expose classes with a private destructor.
Definition: wrap/pybind11/include/pybind11/detail/common.h:1085
select_indices_impl
Make an index sequence of the indices of true arguments.
Definition: wrap/pybind11/include/pybind11/detail/common.h:684
N
#define N
Definition: igam.h:9
error_scope::~error_scope
~error_scope()
Definition: wrap/pybind11/include/pybind11/detail/common.h:1081
Eigen::placeholders::end
static const EIGEN_DEPRECATED end_t end
Definition: IndexedViewHelper.h:181
Base
Definition: test_virtual_functions.cpp:156
format_descriptor< T, detail::enable_if_t< detail::is_same_ignoring_cvref< T, PyObject * >::value > >::format
static std::string format()
Definition: wrap/pybind11/include/pybind11/detail/common.h:1031
builtin_exception
C++ bindings of builtin Python exceptions.
Definition: wrap/pybind11/include/pybind11/detail/common.h:985
constexpr_first
constexpr int constexpr_first()
Definition: wrap/pybind11/include/pybind11/detail/common.h:839
return_value_policy::automatic_reference
@ automatic_reference
any_container::any_container
any_container(std::vector< T > &&v)
Definition: wrap/pybind11/include/pybind11/detail/common.h:1167
enable_if_t
typename std::enable_if< B, T >::type enable_if_t
from cpp_future import (convenient aliases from C++14/17)
Definition: wrap/pybind11/include/pybind11/detail/common.h:640
is_template_base_of_impl::check
static std::true_type check(Base< Us... > *)
test_callbacks.value
value
Definition: test_callbacks.py:158
i
int i
Definition: BiCGSTAB_step_by_step.cpp:9
R
Rot2 R(Rot2::fromAngle(0.1))
overload_cast
Definition: wrap/pybind11/include/pybind11/detail/common.h:1129
remove_reference_t
typename std::remove_reference< T >::type remove_reference_t
Definition: wrap/pybind11/include/pybind11/detail/common.h:646
overload_cast_impl::operator()
constexpr auto operator()(Return(Class::*pmf)(Args...) const, std::true_type) const noexcept -> decltype(pmf)
Definition: wrap/pybind11/include/pybind11/detail/common.h:1105
S
DiscreteKey S(1, 2)
remove_cvref::type
remove_cv_t< remove_reference_t< T > > type
Definition: wrap/pybind11/include/pybind11/detail/common.h:655
any_container::any_container
any_container()=default


gtsam
Author(s):
autogenerated on Wed May 15 2024 15:17:55