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 13
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 0x020D0100
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 #if defined(PYBIND11_CPP20)
122 # define PYBIND11_CONSTINIT constinit
123 # define PYBIND11_DTOR_CONSTEXPR constexpr
124 #else
125 # define PYBIND11_CONSTINIT
126 # define PYBIND11_DTOR_CONSTEXPR
127 #endif
128 
129 // Compiler version assertions
130 #if defined(__INTEL_COMPILER)
131 # if __INTEL_COMPILER < 1800
132 # error pybind11 requires Intel C++ compiler v18 or newer
133 # elif __INTEL_COMPILER < 1900 && defined(PYBIND11_CPP14)
134 # error pybind11 supports only C++11 with Intel C++ compiler v18. Use v19 or newer for C++14.
135 # endif
136 /* The following pragma cannot be pop'ed:
137  https://community.intel.com/t5/Intel-C-Compiler/Inline-and-no-inline-warning/td-p/1216764 */
138 # pragma warning disable 2196 // warning #2196: routine is both "inline" and "noinline"
139 #elif defined(__clang__) && !defined(__apple_build_version__)
140 # if __clang_major__ < 3 || (__clang_major__ == 3 && __clang_minor__ < 3)
141 # error pybind11 requires clang 3.3 or newer
142 # endif
143 #elif defined(__clang__)
144 // Apple changes clang version macros to its Xcode version; the first Xcode release based on
145 // (upstream) clang 3.3 was Xcode 5:
146 # if __clang_major__ < 5
147 # error pybind11 requires Xcode/clang 5.0 or newer
148 # endif
149 #elif defined(__GNUG__)
150 # if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 8)
151 # error pybind11 requires gcc 4.8 or newer
152 # endif
153 #elif defined(_MSC_VER)
154 # if _MSC_VER < 1910
155 # error pybind11 2.10+ requires MSVC 2017 or newer
156 # endif
157 #endif
158 
159 #if !defined(PYBIND11_EXPORT)
160 # if defined(WIN32) || defined(_WIN32)
161 # define PYBIND11_EXPORT __declspec(dllexport)
162 # else
163 # define PYBIND11_EXPORT __attribute__((visibility("default")))
164 # endif
165 #endif
166 
167 #if !defined(PYBIND11_EXPORT_EXCEPTION)
168 # if defined(__apple_build_version__)
169 # define PYBIND11_EXPORT_EXCEPTION PYBIND11_EXPORT
170 # else
171 # define PYBIND11_EXPORT_EXCEPTION
172 # endif
173 #endif
174 
175 // For CUDA, GCC7, GCC8:
176 // PYBIND11_NOINLINE_FORCED is incompatible with `-Wattributes -Werror`.
177 // When defining PYBIND11_NOINLINE_FORCED, it is best to also use `-Wno-attributes`.
178 // However, the measured shared-library size saving when using noinline are only
179 // 1.7% for CUDA, -0.2% for GCC7, and 0.0% for GCC8 (using -DCMAKE_BUILD_TYPE=MinSizeRel,
180 // the default under pybind11/tests).
181 #if !defined(PYBIND11_NOINLINE_FORCED) \
182  && (defined(__CUDACC__) || (defined(__GNUC__) && (__GNUC__ == 7 || __GNUC__ == 8)))
183 # define PYBIND11_NOINLINE_DISABLED
184 #endif
185 
186 // The PYBIND11_NOINLINE macro is for function DEFINITIONS.
187 // In contrast, FORWARD DECLARATIONS should never use this macro:
188 // https://stackoverflow.com/questions/9317473/forward-declaration-of-inline-functions
189 #if defined(PYBIND11_NOINLINE_DISABLED) // Option for maximum portability and experimentation.
190 # define PYBIND11_NOINLINE inline
191 #elif defined(_MSC_VER)
192 # define PYBIND11_NOINLINE __declspec(noinline) inline
193 #else
194 # define PYBIND11_NOINLINE __attribute__((noinline)) inline
195 #endif
196 
197 #if defined(__MINGW32__)
198 // For unknown reasons all PYBIND11_DEPRECATED member trigger a warning when declared
199 // whether it is used or not
200 # define PYBIND11_DEPRECATED(reason)
201 #elif defined(PYBIND11_CPP14)
202 # define PYBIND11_DEPRECATED(reason) [[deprecated(reason)]]
203 #else
204 # define PYBIND11_DEPRECATED(reason) __attribute__((deprecated(reason)))
205 #endif
206 
207 #if defined(PYBIND11_CPP17)
208 # define PYBIND11_MAYBE_UNUSED [[maybe_unused]]
209 #elif defined(_MSC_VER) && !defined(__clang__)
210 # define PYBIND11_MAYBE_UNUSED
211 #else
212 # define PYBIND11_MAYBE_UNUSED __attribute__((__unused__))
213 #endif
214 
215 /* Don't let Python.h #define (v)snprintf as macro because they are implemented
216  properly in Visual Studio since 2015. */
217 #if defined(_MSC_VER)
218 # define HAVE_SNPRINTF 1
219 #endif
220 
222 #if defined(_MSC_VER)
223 PYBIND11_WARNING_PUSH
225 // C4505: 'PySlice_GetIndicesEx': unreferenced local function has been removed (PyPy only)
226 # if defined(_DEBUG) && !defined(Py_DEBUG)
227 // Workaround for a VS 2022 issue.
228 // NOTE: This workaround knowingly violates the Python.h include order requirement:
229 // https://docs.python.org/3/c-api/intro.html#include-files
230 // See https://github.com/pybind/pybind11/pull/3497 for full context.
231 # include <yvals.h>
232 # if _MSVC_STL_VERSION >= 143
233 # include <crtdefs.h>
234 # endif
235 # define PYBIND11_DEBUG_MARKER
236 # undef _DEBUG
237 # endif
238 #endif
239 
240 // https://en.cppreference.com/w/c/chrono/localtime
241 #if defined(__STDC_LIB_EXT1__) && !defined(__STDC_WANT_LIB_EXT1__)
242 # define __STDC_WANT_LIB_EXT1__
243 #endif
244 
245 #ifdef __has_include
246 // std::optional (but including it in c++14 mode isn't allowed)
247 # if defined(PYBIND11_CPP17) && __has_include(<optional>)
248 # define PYBIND11_HAS_OPTIONAL 1
249 # endif
250 // std::experimental::optional (but not allowed in c++11 mode)
251 # if defined(PYBIND11_CPP14) && (__has_include(<experimental/optional>) && \
252  !__has_include(<optional>))
253 # define PYBIND11_HAS_EXP_OPTIONAL 1
254 # endif
255 // std::variant
256 # if defined(PYBIND11_CPP17) && __has_include(<variant>)
257 # define PYBIND11_HAS_VARIANT 1
258 # endif
259 #elif defined(_MSC_VER) && defined(PYBIND11_CPP17)
260 # define PYBIND11_HAS_OPTIONAL 1
261 # define PYBIND11_HAS_VARIANT 1
262 #endif
263 
264 #if defined(PYBIND11_CPP17)
265 # if defined(__has_include)
266 # if __has_include(<string_view>)
267 # define PYBIND11_HAS_STRING_VIEW
268 # endif
269 # elif defined(_MSC_VER)
270 # define PYBIND11_HAS_STRING_VIEW
271 # endif
272 #endif
273 
274 #include <Python.h>
275 #if PY_VERSION_HEX < 0x03070000
276 # error "PYTHON < 3.7 IS UNSUPPORTED. pybind11 v2.12 was the last to support Python 3.6."
277 #endif
278 #include <frameobject.h>
279 #include <pythread.h>
280 
281 /* Python #defines overrides on all sorts of core functions, which
282  tends to weak havok in C++ codebases that expect these to work
283  like regular functions (potentially with several overloads) */
284 #if defined(isalnum)
285 # undef isalnum
286 # undef isalpha
287 # undef islower
288 # undef isspace
289 # undef isupper
290 # undef tolower
291 # undef toupper
292 #endif
293 
294 #if defined(copysign)
295 # undef copysign
296 #endif
297 
298 #if defined(PYBIND11_NUMPY_1_ONLY)
299 # define PYBIND11_INTERNAL_NUMPY_1_ONLY_DETECTED
300 #endif
301 
302 #if defined(PYPY_VERSION) && !defined(PYBIND11_SIMPLE_GIL_MANAGEMENT)
303 # define PYBIND11_SIMPLE_GIL_MANAGEMENT
304 #endif
305 
306 #if defined(_MSC_VER)
307 # if defined(PYBIND11_DEBUG_MARKER)
308 # define _DEBUG
309 # undef PYBIND11_DEBUG_MARKER
310 # endif
312 #endif
313 
314 #include <cstddef>
315 #include <cstring>
316 #include <exception>
317 #include <forward_list>
318 #include <memory>
319 #include <stdexcept>
320 #include <string>
321 #include <type_traits>
322 #include <typeindex>
323 #include <unordered_map>
324 #include <unordered_set>
325 #include <vector>
326 #if defined(__has_include)
327 # if __has_include(<version>)
328 # include <version>
329 # endif
330 #endif
331 
332 // Must be after including <version> or one of the other headers specified by the standard
333 #if defined(__cpp_lib_char8_t) && __cpp_lib_char8_t >= 201811L
334 # define PYBIND11_HAS_U8STRING
335 #endif
336 
337 // See description of PR #4246:
338 #if !defined(PYBIND11_NO_ASSERT_GIL_HELD_INCREF_DECREF) && !defined(NDEBUG) \
339  && !defined(PYPY_VERSION) && !defined(PYBIND11_ASSERT_GIL_HELD_INCREF_DECREF)
340 # define PYBIND11_ASSERT_GIL_HELD_INCREF_DECREF
341 #endif
342 
343 // #define PYBIND11_STR_LEGACY_PERMISSIVE
344 // If DEFINED, pybind11::str can hold PyUnicodeObject or PyBytesObject
345 // (probably surprising and never documented, but this was the
346 // legacy behavior until and including v2.6.x). As a side-effect,
347 // pybind11::isinstance<str>() is true for both pybind11::str and
348 // pybind11::bytes.
349 // If UNDEFINED, pybind11::str can only hold PyUnicodeObject, and
350 // pybind11::isinstance<str>() is true only for pybind11::str.
351 // However, for Python 2 only (!), the pybind11::str caster
352 // implicitly decoded bytes to PyUnicodeObject. This was to ease
353 // the transition from the legacy behavior to the non-permissive
354 // behavior.
355 
357 #define PYBIND11_INSTANCE_METHOD_NEW(ptr, class_) PyInstanceMethod_New(ptr)
358 #define PYBIND11_INSTANCE_METHOD_CHECK PyInstanceMethod_Check
359 #define PYBIND11_INSTANCE_METHOD_GET_FUNCTION PyInstanceMethod_GET_FUNCTION
360 #define PYBIND11_BYTES_CHECK PyBytes_Check
361 #define PYBIND11_BYTES_FROM_STRING PyBytes_FromString
362 #define PYBIND11_BYTES_FROM_STRING_AND_SIZE PyBytes_FromStringAndSize
363 #define PYBIND11_BYTES_AS_STRING_AND_SIZE PyBytes_AsStringAndSize
364 #define PYBIND11_BYTES_AS_STRING PyBytes_AsString
365 #define PYBIND11_BYTES_SIZE PyBytes_Size
366 #define PYBIND11_LONG_CHECK(o) PyLong_Check(o)
367 #define PYBIND11_LONG_AS_LONGLONG(o) PyLong_AsLongLong(o)
368 #define PYBIND11_LONG_FROM_SIGNED(o) PyLong_FromSsize_t((ssize_t) (o))
369 #define PYBIND11_LONG_FROM_UNSIGNED(o) PyLong_FromSize_t((size_t) (o))
370 #define PYBIND11_BYTES_NAME "bytes"
371 #define PYBIND11_STRING_NAME "str"
372 #define PYBIND11_SLICE_OBJECT PyObject
373 #define PYBIND11_FROM_STRING PyUnicode_FromString
374 #define PYBIND11_STR_TYPE ::pybind11::str
375 #define PYBIND11_BOOL_ATTR "__bool__"
376 #define PYBIND11_NB_BOOL(ptr) ((ptr)->nb_bool)
377 #define PYBIND11_BUILTINS_MODULE "builtins"
378 // Providing a separate declaration to make Clang's -Wmissing-prototypes happy.
379 // See comment for PYBIND11_MODULE below for why this is marked "maybe unused".
380 #define PYBIND11_PLUGIN_IMPL(name) \
381  extern "C" PYBIND11_MAYBE_UNUSED PYBIND11_EXPORT PyObject *PyInit_##name(); \
382  extern "C" PYBIND11_EXPORT PyObject *PyInit_##name()
383 
384 #define PYBIND11_TRY_NEXT_OVERLOAD ((PyObject *) 1) // special failure return code
385 #define PYBIND11_STRINGIFY(x) #x
386 #define PYBIND11_TOSTRING(x) PYBIND11_STRINGIFY(x)
387 #define PYBIND11_CONCAT(first, second) first##second
388 #define PYBIND11_ENSURE_INTERNALS_READY pybind11::detail::get_internals();
389 
390 #define PYBIND11_CHECK_PYTHON_VERSION \
391  { \
392  const char *compiled_ver \
393  = PYBIND11_TOSTRING(PY_MAJOR_VERSION) "." PYBIND11_TOSTRING(PY_MINOR_VERSION); \
394  const char *runtime_ver = Py_GetVersion(); \
395  size_t len = std::strlen(compiled_ver); \
396  if (std::strncmp(runtime_ver, compiled_ver, len) != 0 \
397  || (runtime_ver[len] >= '0' && runtime_ver[len] <= '9')) { \
398  PyErr_Format(PyExc_ImportError, \
399  "Python version mismatch: module was compiled for Python %s, " \
400  "but the interpreter version is incompatible: %s.", \
401  compiled_ver, \
402  runtime_ver); \
403  return nullptr; \
404  } \
405  }
406 
407 #define PYBIND11_CATCH_INIT_EXCEPTIONS \
408  catch (pybind11::error_already_set & e) { \
409  pybind11::raise_from(e, PyExc_ImportError, "initialization failed"); \
410  return nullptr; \
411  } \
412  catch (const std::exception &e) { \
413  ::pybind11::set_error(PyExc_ImportError, e.what()); \
414  return nullptr; \
415  }
416 
429 
432 #define PYBIND11_PLUGIN(name) \
433  PYBIND11_DEPRECATED("PYBIND11_PLUGIN is deprecated, use PYBIND11_MODULE") \
434  static PyObject *pybind11_init(); \
435  PYBIND11_PLUGIN_IMPL(name) { \
436  PYBIND11_CHECK_PYTHON_VERSION \
437  PYBIND11_ENSURE_INTERNALS_READY \
438  try { \
439  return pybind11_init(); \
440  } \
441  PYBIND11_CATCH_INIT_EXCEPTIONS \
442  } \
443  PyObject *pybind11_init()
444 
466 #define PYBIND11_MODULE(name, variable, ...) \
467  static ::pybind11::module_::module_def PYBIND11_CONCAT(pybind11_module_def_, name) \
468  PYBIND11_MAYBE_UNUSED; \
469  PYBIND11_MAYBE_UNUSED \
470  static void PYBIND11_CONCAT(pybind11_init_, name)(::pybind11::module_ &); \
471  PYBIND11_PLUGIN_IMPL(name) { \
472  PYBIND11_CHECK_PYTHON_VERSION \
473  PYBIND11_ENSURE_INTERNALS_READY \
474  auto m = ::pybind11::module_::create_extension_module( \
475  PYBIND11_TOSTRING(name), \
476  nullptr, \
477  &PYBIND11_CONCAT(pybind11_module_def_, name), \
478  ##__VA_ARGS__); \
479  try { \
480  PYBIND11_CONCAT(pybind11_init_, name)(m); \
481  return m.ptr(); \
482  } \
483  PYBIND11_CATCH_INIT_EXCEPTIONS \
484  } \
485  void PYBIND11_CONCAT(pybind11_init_, name)(::pybind11::module_ & (variable))
486 
488 
489 using ssize_t = Py_ssize_t;
490 using size_t = std::size_t;
491 
492 template <typename IntType>
493 inline ssize_t ssize_t_cast(const IntType &val) {
494  static_assert(sizeof(IntType) <= sizeof(ssize_t), "Implicit narrowing is not permitted.");
495  return static_cast<ssize_t>(val);
496 }
497 
505  automatic = 0,
506 
512 
518 
522  copy,
523 
528  move,
529 
535  reference,
536 
548 };
549 
551 
552 inline static constexpr int log2(size_t n, int k = 0) {
553  return (n <= 1) ? k : log2(n >> 1, k + 1);
554 }
555 
556 // Returns the size as a multiple of sizeof(void *), rounded up.
557 inline static constexpr size_t size_in_ptrs(size_t s) {
558  return 1 + ((s - 1) >> log2(sizeof(void *)));
559 }
560 
567 constexpr size_t instance_simple_holder_in_ptrs() {
568  static_assert(sizeof(std::shared_ptr<int>) >= sizeof(std::unique_ptr<int>),
569  "pybind assumes std::shared_ptrs are at least as big as std::unique_ptrs");
570  return size_in_ptrs(sizeof(std::shared_ptr<int>));
571 }
572 
573 // Forward declarations
574 struct type_info;
575 struct value_and_holder;
576 
580 };
581 
583 struct instance {
584  PyObject_HEAD
586  union {
589  };
591  PyObject *weakrefs;
593  bool owned : 1;
617  bool simple_layout : 1;
623  bool has_patients : 1;
624 
627  void allocate_layout();
628 
630  void deallocate_layout();
631 
635  value_and_holder get_value_and_holder(const type_info *find_type = nullptr,
636  bool throw_if_missing = true);
637 
639  static constexpr uint8_t status_holder_constructed = 1;
640  static constexpr uint8_t status_instance_registered = 2;
641 };
642 
644  "Internal error: `pybind11::detail::instance` is not standard layout!");
645 
647 #if defined(PYBIND11_CPP14)
648 using std::conditional_t;
649 using std::enable_if_t;
650 using std::remove_cv_t;
652 #else
653 template <bool B, typename T = void>
655 template <bool B, typename T, typename F>
657 template <typename T>
659 template <typename T>
661 #endif
662 
663 #if defined(PYBIND11_CPP20)
664 using std::remove_cvref;
665 using std::remove_cvref_t;
666 #else
667 template <class T>
668 struct remove_cvref {
670 };
671 template <class T>
673 #endif
674 
676 template <typename T, typename U>
677 using is_same_ignoring_cvref = std::is_same<detail::remove_cvref_t<T>, U>;
678 
680 #if defined(PYBIND11_CPP14)
681 using std::index_sequence;
683 #else
684 template <size_t...>
685 struct index_sequence {};
686 template <size_t N, size_t... S>
687 struct make_index_sequence_impl : make_index_sequence_impl<N - 1, N - 1, S...> {};
688 template <size_t... S>
690  using type = index_sequence<S...>;
691 };
692 template <size_t N>
694 #endif
695 
697 template <typename ISeq, size_t, bool...>
699  using type = ISeq;
700 };
701 template <size_t... IPrev, size_t I, bool B, bool... Bs>
702 struct select_indices_impl<index_sequence<IPrev...>, I, B, Bs...>
703  : select_indices_impl<conditional_t<B, index_sequence<IPrev..., I>, index_sequence<IPrev...>>,
704  I + 1,
705  Bs...> {};
706 template <bool... Bs>
708 
710 template <bool B>
711 using bool_constant = std::integral_constant<bool, B>;
712 template <typename T>
713 struct negation : bool_constant<!T::value> {};
714 
715 // PGI/Intel cannot detect operator delete with the "compatible" void_t impl, so
716 // using the new one (C++14 defect, so generally works on newer compilers, even
717 // if not in C++17 mode)
718 #if defined(__PGIC__) || defined(__INTEL_COMPILER)
719 template <typename...>
720 using void_t = void;
721 #else
722 template <typename...>
723 struct void_t_impl {
724  using type = void;
725 };
726 template <typename... Ts>
727 using void_t = typename void_t_impl<Ts...>::type;
728 #endif
729 
731 #if defined(__cpp_fold_expressions) && !(defined(_MSC_VER) && (_MSC_VER < 1916))
732 template <class... Ts>
733 using all_of = bool_constant<(Ts::value && ...)>;
734 template <class... Ts>
735 using any_of = bool_constant<(Ts::value || ...)>;
736 #elif !defined(_MSC_VER)
737 template <bool...>
738 struct bools {};
739 template <class... Ts>
740 using all_of = std::is_same<bools<Ts::value..., true>, bools<true, Ts::value...>>;
741 template <class... Ts>
743 #else
744 // MSVC has trouble with the above, but supports std::conjunction, which we can use instead (albeit
745 // at a slight loss of compilation efficiency).
746 template <class... Ts>
747 using all_of = std::conjunction<Ts...>;
748 template <class... Ts>
749 using any_of = std::disjunction<Ts...>;
750 #endif
751 template <class... Ts>
752 using none_of = negation<any_of<Ts...>>;
753 
754 template <class T, template <class> class... Predicates>
756 template <class T, template <class> class... Predicates>
758 template <class T, template <class> class... Predicates>
760 
762 template <typename T>
763 struct remove_class {};
764 template <typename C, typename R, typename... A>
765 struct remove_class<R (C::*)(A...)> {
766  using type = R(A...);
767 };
768 template <typename C, typename R, typename... A>
769 struct remove_class<R (C::*)(A...) const> {
770  using type = R(A...);
771 };
772 #ifdef __cpp_noexcept_function_type
773 template <typename C, typename R, typename... A>
774 struct remove_class<R (C::*)(A...) noexcept> {
775  using type = R(A...);
776 };
777 template <typename C, typename R, typename... A>
778 struct remove_class<R (C::*)(A...) const noexcept> {
779  using type = R(A...);
780 };
781 #endif
782 template <typename T>
785  using type = T;
786 };
787 template <typename T>
788 struct intrinsic_type<const T> {
789  using type = typename intrinsic_type<T>::type;
790 };
791 template <typename T>
792 struct intrinsic_type<T *> {
793  using type = typename intrinsic_type<T>::type;
794 };
795 template <typename T>
796 struct intrinsic_type<T &> {
797  using type = typename intrinsic_type<T>::type;
798 };
799 template <typename T>
800 struct intrinsic_type<T &&> {
801  using type = typename intrinsic_type<T>::type;
802 };
803 template <typename T, size_t N>
804 struct intrinsic_type<const T[N]> {
805  using type = typename intrinsic_type<T>::type;
806 };
807 template <typename T, size_t N>
808 struct intrinsic_type<T[N]> {
809  using type = typename intrinsic_type<T>::type;
810 };
811 template <typename T>
813 
815 struct void_type {};
816 
818 template <typename...>
819 struct type_list {};
820 
822 #ifdef __cpp_fold_expressions
823 template <typename... Ts>
824 constexpr size_t constexpr_sum(Ts... ns) {
825  return (0 + ... + size_t{ns});
826 }
827 #else
828 constexpr size_t constexpr_sum() { return 0; }
829 template <typename T, typename... Ts>
830 constexpr size_t constexpr_sum(T n, Ts... ns) {
831  return size_t{n} + constexpr_sum(ns...);
832 }
833 #endif
834 
835 PYBIND11_NAMESPACE_BEGIN(constexpr_impl)
837 constexpr int first(int i) { return i; }
838 template <typename T, typename... Ts>
839 constexpr int first(int i, T v, Ts... vs) {
840  return v ? i : first(i + 1, vs...);
841 }
842 
843 constexpr int last(int /*i*/, int result) { return result; }
844 template <typename T, typename... Ts>
845 constexpr int last(int i, int result, T v, Ts... vs) {
846  return last(i + 1, v ? i : result, vs...);
847 }
848 PYBIND11_NAMESPACE_END(constexpr_impl)
849 
850 template <template <typename> class Predicate, typename... Ts>
853 constexpr int constexpr_first() {
855 }
856 
858 template <template <typename> class Predicate, typename... Ts>
859 constexpr int constexpr_last() {
860  return constexpr_impl::last(0, -1, Predicate<Ts>::value...);
861 }
862 
864 template <size_t N, typename T, typename... Ts>
865 struct pack_element {
866  using type = typename pack_element<N - 1, Ts...>::type;
867 };
868 template <typename T, typename... Ts>
869 struct pack_element<0, T, Ts...> {
870  using type = T;
871 };
872 
875 template <template <typename> class Predicate, typename Default, typename... Ts>
876 struct exactly_one {
877  static constexpr auto found = constexpr_sum(Predicate<Ts>::value...);
878  static_assert(found <= 1, "Found more than one type matching the predicate");
879 
880  static constexpr auto index = found ? constexpr_first<Predicate, Ts...>() : 0;
882 };
883 template <template <typename> class P, typename Default>
885  using type = Default;
886 };
887 
888 template <template <typename> class Predicate, typename Default, typename... Ts>
889 using exactly_one_t = typename exactly_one<Predicate, Default, Ts...>::type;
890 
892 template <typename T, typename... /*Us*/>
894  using type = T;
895 };
896 template <typename T, typename... Us>
897 using deferred_t = typename deferred_type<T, Us...>::type;
898 
901 template <typename Base, typename Derived>
902 using is_strict_base_of
904 
908 template <typename Base, typename Derived>
912 
913 template <template <typename...> class Base>
915  template <typename... Us>
916  static std::true_type check(Base<Us...> *);
917  static std::false_type check(...);
918 };
919 
922 template <template <typename...> class Base, typename T>
923 // Sadly, all MSVC versions incl. 2022 need the workaround, even in C++20 mode.
924 // See also: https://github.com/pybind/pybind11/pull/3741
925 #if !defined(_MSC_VER)
928 #else
929 struct is_template_base_of
930  : decltype(is_template_base_of_impl<Base>::check((intrinsic_t<T> *) nullptr)){};
931 #endif
932 
935 template <template <typename...> class Class, typename T>
936 struct is_instantiation : std::false_type {};
937 template <template <typename...> class Class, typename... Us>
938 struct is_instantiation<Class, Class<Us...>> : std::true_type {};
939 
941 template <typename T>
943 
945 template <typename T, typename = void>
946 struct is_input_iterator : std::false_type {};
947 template <typename T>
949  void_t<decltype(*std::declval<T &>()), decltype(++std::declval<T &>())>>
950  : std::true_type {};
951 
952 template <typename T>
956 
957 template <typename F>
959  // If you are encountering an
960  // 'error: name followed by "::" must be a class or namespace name'
961  // with the Intel compiler and a noexcept function here,
962  // try to use noexcept(true) instead of plain noexcept.
963  using type = typename remove_class<decltype(&F::operator())>::type;
964 };
965 
966 // Extracts the function signature from a function, function pointer or lambda.
967 template <typename Function, typename F = remove_reference_t<Function>>
970  F,
972  std::remove_pointer<F>,
974 
978 template <typename T>
980  std::is_function,
981  std::is_pointer,
982  std::is_member_pointer>;
983 
984 // [workaround(intel)] Internal error on fold expression
986 #if defined(__cpp_fold_expressions) && !defined(__INTEL_COMPILER)
987 // Intel compiler produces an internal error on this fold expression (tested with ICC 19.0.2)
988 # define PYBIND11_EXPAND_SIDE_EFFECTS(PATTERN) (((PATTERN), void()), ...)
989 #else
990 using expand_side_effects = bool[];
991 # define PYBIND11_EXPAND_SIDE_EFFECTS(PATTERN) \
992  (void) pybind11::detail::expand_side_effects { ((PATTERN), void(), false)..., false }
993 #endif
994 
996 
997 class PYBIND11_EXPORT_EXCEPTION builtin_exception : public std::runtime_error {
999 public:
1000  using std::runtime_error::runtime_error;
1002  virtual void set_error() const = 0;
1003 };
1004 
1005 #define PYBIND11_RUNTIME_EXCEPTION(name, type) \
1006  class PYBIND11_EXPORT_EXCEPTION name : public builtin_exception { \
1007  public: \
1008  using builtin_exception::builtin_exception; \
1009  name() : name("") {} \
1010  void set_error() const override { PyErr_SetString(type, what()); } \
1011  };
1012 
1013 PYBIND11_RUNTIME_EXCEPTION(stop_iteration, PyExc_StopIteration)
1014 PYBIND11_RUNTIME_EXCEPTION(index_error, PyExc_IndexError)
1015 PYBIND11_RUNTIME_EXCEPTION(key_error, PyExc_KeyError)
1016 PYBIND11_RUNTIME_EXCEPTION(value_error, PyExc_ValueError)
1017 PYBIND11_RUNTIME_EXCEPTION(type_error, PyExc_TypeError)
1018 PYBIND11_RUNTIME_EXCEPTION(buffer_error, PyExc_BufferError)
1019 PYBIND11_RUNTIME_EXCEPTION(import_error, PyExc_ImportError)
1020 PYBIND11_RUNTIME_EXCEPTION(attribute_error, PyExc_AttributeError)
1021 PYBIND11_RUNTIME_EXCEPTION(cast_error, PyExc_RuntimeError)
1022 PYBIND11_RUNTIME_EXCEPTION(reference_cast_error, PyExc_RuntimeError)
1025 
1026 [[noreturn]] PYBIND11_NOINLINE void pybind11_fail(const char *reason) {
1027  assert(!PyErr_Occurred());
1028  throw std::runtime_error(reason);
1029 }
1030 [[noreturn]] PYBIND11_NOINLINE void pybind11_fail(const std::string &reason) {
1031  assert(!PyErr_Occurred());
1032  throw std::runtime_error(reason);
1033 }
1034 
1035 template <typename T, typename SFINAE = void>
1037 
1038 template <typename T>
1040  T,
1041  detail::enable_if_t<detail::is_same_ignoring_cvref<T, PyObject *>::value>> {
1042  static constexpr const char c = 'O';
1043  static constexpr const char value[2] = {c, '\0'};
1044  static std::string format() { return std::string(1, c); }
1045 };
1046 
1048 // Returns the index of the given type in the type char array below, and in the list in numpy.h
1049 // The order here is: bool; 8 ints ((signed,unsigned)x(8,16,32,64)bits); float,double,long double;
1050 // complex float,double,long double. Note that the long double types only participate when long
1051 // double is actually longer than double (it isn't under MSVC).
1052 // NB: not only the string below but also complex.h and numpy.h rely on this order.
1053 template <typename T, typename SFINAE = void>
1055  static constexpr bool value = false;
1056 };
1057 template <typename T>
1058 struct is_fmt_numeric<T, enable_if_t<std::is_arithmetic<T>::value>> {
1059  static constexpr bool value = true;
1060  static constexpr int index
1062  ? 0
1063  : 1
1065  ? detail::log2(sizeof(T)) * 2 + std::is_unsigned<T>::value
1066  : 8
1069  : 0));
1070 };
1072 
1073 template <typename T>
1074 struct format_descriptor<T, detail::enable_if_t<std::is_arithmetic<T>::value>> {
1075  static constexpr const char c = "?bBhHiIqQfdg"[detail::is_fmt_numeric<T>::index];
1076  static constexpr const char value[2] = {c, '\0'};
1077  static std::string format() { return std::string(1, c); }
1078 };
1079 
1080 #if !defined(PYBIND11_CPP17)
1081 
1082 template <typename T>
1083 constexpr const char
1085 
1086 #endif
1087 
1089 struct error_scope {
1090  PyObject *type, *value, *trace;
1091  error_scope() { PyErr_Fetch(&type, &value, &trace); }
1092  error_scope(const error_scope &) = delete;
1093  error_scope &operator=(const error_scope &) = delete;
1094  ~error_scope() { PyErr_Restore(type, value, trace); }
1095 };
1096 
1098 struct nodelete {
1099  template <typename T>
1100  void operator()(T *) {}
1101 };
1102 
1104 template <typename... Args>
1106  template <typename Return>
1107  constexpr auto operator()(Return (*pf)(Args...)) const noexcept -> decltype(pf) {
1108  return pf;
1109  }
1110 
1111  template <typename Return, typename Class>
1112  constexpr auto operator()(Return (Class::*pmf)(Args...),
1113  std::false_type = {}) const noexcept -> decltype(pmf) {
1114  return pmf;
1115  }
1116 
1117  template <typename Return, typename Class>
1118  constexpr auto operator()(Return (Class::*pmf)(Args...) const,
1119  std::true_type) const noexcept -> decltype(pmf) {
1120  return pmf;
1121  }
1122 };
1124 
1125 // overload_cast requires variable templates: C++14
1126 #if defined(PYBIND11_CPP14)
1127 # define PYBIND11_OVERLOAD_CAST 1
1128 template <typename... Args>
1132 static constexpr detail::overload_cast_impl<Args...> overload_cast{};
1133 #endif
1134 
1138 static constexpr auto const_ = std::true_type{};
1139 
1140 #if !defined(PYBIND11_CPP14) // no overload_cast: providing something that static_assert-fails:
1141 template <typename... Args>
1144  "pybind11::overload_cast<...> requires compiling in C++14 mode");
1145 };
1146 #endif // overload_cast
1147 
1149 
1150 // Adaptor for converting arbitrary container arguments into a vector; implicitly convertible from
1151 // any standard container (or C-style array) supporting std::begin/std::end, any singleton
1152 // arithmetic type (if T is arithmetic), or explicitly constructible from an iterator pair.
1153 template <typename T>
1155  std::vector<T> v;
1156 
1157 public:
1158  any_container() = default;
1159 
1160  // Can construct from a pair of iterators
1163 
1164  // Implicit conversion constructor from any arbitrary container type
1165  // with values convertible to T
1166  template <typename Container,
1167  typename = enable_if_t<
1168  std::is_convertible<decltype(*std::begin(std::declval<const Container &>())),
1169  T>::value>>
1170  // NOLINTNEXTLINE(google-explicit-constructor)
1171  any_container(const Container &c) : any_container(std::begin(c), std::end(c)) {}
1172 
1173  // initializer_list's aren't deducible, so don't get matched by the above template;
1174  // we need this to explicitly allow implicit conversion from one:
1176  any_container(const std::initializer_list<TIn> &c) : any_container(c.begin(), c.end()) {}
1177 
1178  // Avoid copying if given an rvalue vector of the correct type.
1179  // NOLINTNEXTLINE(google-explicit-constructor)
1180  any_container(std::vector<T> &&v) : v(std::move(v)) {}
1181 
1182  // Moves the vector out of an rvalue any_container
1183  // NOLINTNEXTLINE(google-explicit-constructor)
1184  operator std::vector<T> &&() && { return std::move(v); }
1185 
1186  // Dereferencing obtains a reference to the underlying vector
1187  std::vector<T> &operator*() { return v; }
1188  const std::vector<T> &operator*() const { return v; }
1189 
1190  // -> lets you call methods on the underlying vector
1191  std::vector<T> *operator->() { return &v; }
1192  const std::vector<T> *operator->() const { return &v; }
1193 };
1194 
1195 // Forward-declaration; see detail/class.h
1196 std::string get_fully_qualified_tp_name(PyTypeObject *);
1197 
1198 template <typename T>
1199 inline static std::shared_ptr<T>
1200 try_get_shared_from_this(std::enable_shared_from_this<T> *holder_value_ptr) {
1201 // Pre C++17, this code path exploits undefined behavior, but is known to work on many platforms.
1202 // Use at your own risk!
1203 // See also https://en.cppreference.com/w/cpp/memory/enable_shared_from_this, and in particular
1204 // the `std::shared_ptr<Good> gp1 = not_so_good.getptr();` and `try`-`catch` parts of the example.
1205 #if defined(__cpp_lib_enable_shared_from_this) && (!defined(_MSC_VER) || _MSC_VER >= 1912)
1206  return holder_value_ptr->weak_from_this().lock();
1207 #else
1208  try {
1209  return holder_value_ptr->shared_from_this();
1210  } catch (const std::bad_weak_ptr &) {
1211  return nullptr;
1212  }
1213 #endif
1214 }
1215 
1216 // For silencing "unused" compiler warnings in special situations.
1217 template <typename... Args>
1218 #if defined(_MSC_VER) && _MSC_VER < 1920 // MSVC 2017
1219 constexpr
1220 #endif
1221  inline void
1223 }
1224 
1225 // MSVC warning C4100: Unreferenced formal parameter
1226 #if defined(_MSC_VER) && _MSC_VER <= 1916
1227 # define PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(...) \
1228  detail::silence_unused_warnings(__VA_ARGS__)
1229 #else
1230 # define PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(...)
1231 #endif
1232 
1233 // GCC -Wunused-but-set-parameter All GCC versions (as of July 2021).
1234 #if defined(__GNUG__) && !defined(__clang__) && !defined(__INTEL_COMPILER)
1235 # define PYBIND11_WORKAROUND_INCORRECT_GCC_UNUSED_BUT_SET_PARAMETER(...) \
1236  detail::silence_unused_warnings(__VA_ARGS__)
1237 #else
1238 # define PYBIND11_WORKAROUND_INCORRECT_GCC_UNUSED_BUT_SET_PARAMETER(...)
1239 #endif
1240 
1241 #if defined(__clang__) \
1242  && (defined(__apple_build_version__) /* AppleClang 13.0.0.13000029 was the only data point \
1243  available. */ \
1244  || (__clang_major__ >= 7 \
1245  && __clang_major__ <= 12) /* Clang 3, 5, 13, 14, 15 do not generate the warning. */ \
1246  )
1247 # define PYBIND11_DETECTED_CLANG_WITH_MISLEADING_CALL_STD_MOVE_EXPLICITLY_WARNING
1248 // Example:
1249 // tests/test_kwargs_and_defaults.cpp:46:68: error: local variable 'args' will be copied despite
1250 // being returned by name [-Werror,-Wreturn-std-move]
1251 // m.def("args_function", [](py::args args) -> py::tuple { return args; });
1252 // ^~~~
1253 // test_kwargs_and_defaults.cpp:46:68: note: call 'std::move' explicitly to avoid copying
1254 // m.def("args_function", [](py::args args) -> py::tuple { return args; });
1255 // ^~~~
1256 // std::move(args)
1257 #endif
1258 
1259 // Pybind offers detailed error messages by default for all builts that are debug (through the
1260 // negation of NDEBUG). This can also be manually enabled by users, for any builds, through
1261 // defining PYBIND11_DETAILED_ERROR_MESSAGES. This information is primarily useful for those
1262 // who are writing (as opposed to merely using) libraries that use pybind11.
1263 #if !defined(PYBIND11_DETAILED_ERROR_MESSAGES) && !defined(NDEBUG)
1264 # define PYBIND11_DETAILED_ERROR_MESSAGES
1265 #endif
1266 
select_indices
typename select_indices_impl< index_sequence<>, 0, Bs... >::type select_indices
Definition: wrap/pybind11/include/pybind11/detail/common.h:707
return_value_policy::reference_internal
@ reference_internal
format_descriptor
Definition: wrap/pybind11/include/pybind11/detail/common.h:1036
nonsimple_values_and_holders
Definition: wrap/pybind11/include/pybind11/detail/common.h:577
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:740
error_scope
RAII wrapper that temporarily clears any Python error state.
Definition: wrap/pybind11/include/pybind11/detail/common.h:1089
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:990
pack_element
Return the Nth element from the parameter pack.
Definition: wrap/pybind11/include/pybind11/detail/common.h:865
is_instantiation
Definition: wrap/pybind11/include/pybind11/detail/common.h:936
B
Matrix< SCALARB, Dynamic, Dynamic, opt_B > B
Definition: bench_gemm.cpp:49
is_fmt_numeric
Definition: wrap/pybind11/include/pybind11/detail/common.h:1054
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:955
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:963
intrinsic_type
Helper template to strip away type modifiers.
Definition: wrap/pybind11/include/pybind11/detail/common.h:784
index_sequence
Index sequences.
Definition: wrap/pybind11/include/pybind11/detail/common.h:685
gtsam.examples.DogLegOptimizerExample.type
type
Definition: DogLegOptimizerExample.py:111
ssize_t
Py_ssize_t ssize_t
Definition: wrap/pybind11/include/pybind11/detail/common.h:489
instance::simple_layout
bool simple_layout
Definition: wrap/pybind11/include/pybind11/detail/common.h:617
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:567
s
RealScalar s
Definition: level1_cplx_impl.h:126
instance::nonsimple
nonsimple_values_and_holders nonsimple
Definition: wrap/pybind11/include/pybind11/detail/common.h:588
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:499
exactly_one::found
static constexpr auto found
Definition: wrap/pybind11/include/pybind11/detail/common.h:877
any_container::operator->
const std::vector< T > * operator->() const
Definition: wrap/pybind11/include/pybind11/detail/common.h:1192
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:410
void_t
typename void_t_impl< Ts... >::type void_t
Definition: wrap/pybind11/include/pybind11/detail/common.h:727
is_template_base_of_impl
Definition: wrap/pybind11/include/pybind11/detail/common.h:914
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:640
constexpr_sum
constexpr size_t constexpr_sum()
Compile-time integer sum.
Definition: wrap/pybind11/include/pybind11/detail/common.h:828
exactly_one
Definition: wrap/pybind11/include/pybind11/detail/common.h:876
any_container::any_container
any_container(It first, It last)
Definition: wrap/pybind11/include/pybind11/detail/common.h:1162
error_scope::error_scope
error_scope()
Definition: wrap/pybind11/include/pybind11/detail/common.h:1091
remove_cv_t
typename std::remove_cv< T >::type remove_cv_t
Definition: wrap/pybind11/include/pybind11/detail/common.h:658
deferred_t
typename deferred_type< T, Us... >::type deferred_t
Definition: wrap/pybind11/include/pybind11/detail/common.h:897
const_
static constexpr auto const_
Definition: wrap/pybind11/include/pybind11/detail/common.h:1138
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:1200
error_scope::trace
PyObject * trace
Definition: wrap/pybind11/include/pybind11/detail/common.h:1090
remove_class
Strip the class from a method type.
Definition: wrap/pybind11/include/pybind11/detail/common.h:763
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:687
PYBIND11_NOINLINE
#define PYBIND11_NOINLINE
Definition: wrap/pybind11/include/pybind11/detail/common.h:194
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:927
type
Definition: pytypes.h:1525
value_and_holder
Definition: type_caster_base.h:262
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:738
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:1077
nonsimple_values_and_holders::values_and_holders
void ** values_and_holders
Definition: wrap/pybind11/include/pybind11/detail/common.h:578
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:1155
size_in_ptrs
static constexpr size_t size_in_ptrs(size_t s)
Definition: wrap/pybind11/include/pybind11/detail/common.h:557
log2
static constexpr int log2(size_t n, int k=0)
Definition: wrap/pybind11/include/pybind11/detail/common.h:552
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:587
nonsimple_values_and_holders::status
uint8_t * status
Definition: wrap/pybind11/include/pybind11/detail/common.h:579
result
Values result
Definition: OdometryOptimize.cpp:8
any_container::operator->
std::vector< T > * operator->()
Definition: wrap/pybind11/include/pybind11/detail/common.h:1191
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:1005
remove_cvref
Definition: wrap/pybind11/include/pybind11/detail/common.h:668
uint8_t
unsigned char uint8_t
Definition: ms_stdint.h:83
instance::allocate_layout
void allocate_layout()
Definition: type_caster_base.h:440
conditional_t
typename std::conditional< B, T, F >::type conditional_t
Definition: wrap/pybind11/include/pybind11/detail/common.h:656
type_list
Helper template which holds a list of types.
Definition: wrap/pybind11/include/pybind11/detail/common.h:819
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:583
exactly_one::type
conditional_t< found, typename pack_element< index, Ts... >::type, Default > type
Definition: wrap/pybind11/include/pybind11/detail/common.h:881
n
int n
Definition: BiCGSTAB_simple.cpp:1
any_container
Definition: wrap/pybind11/include/pybind11/detail/common.h:1154
satisfies_all_of
all_of< Predicates< T >... > satisfies_all_of
Definition: wrap/pybind11/include/pybind11/detail/common.h:755
is_fmt_numeric::value
static constexpr bool value
Definition: wrap/pybind11/include/pybind11/detail/common.h:1055
any_container::any_container
any_container(const Container &c)
Definition: wrap/pybind11/include/pybind11/detail/common.h:1171
exactly_one_t
typename exactly_one< Predicate, Default, Ts... >::type exactly_one_t
Definition: wrap/pybind11/include/pybind11/detail/common.h:889
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:812
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:866
return_value_policy::copy
@ copy
PYBIND11_EXPORT_EXCEPTION
#define PYBIND11_EXPORT_EXCEPTION
Definition: wrap/pybind11/include/pybind11/detail/common.h:171
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:621
instance::deallocate_layout
void deallocate_layout()
Destroys/deallocates all of the above.
Definition: type_caster_base.h:489
first
constexpr int first(int i)
Implementation details for constexpr functions.
Definition: wrap/pybind11/include/pybind11/detail/common.h:837
remove_cvref_t
typename remove_cvref< T >::type remove_cvref_t
Definition: wrap/pybind11/include/pybind11/detail/common.h:672
return_value_policy::reference
@ reference
overload_cast_impl
Definition: wrap/pybind11/include/pybind11/detail/common.h:1105
negation
Definition: wrap/pybind11/include/pybind11/detail/common.h:713
any_container::operator*
std::vector< T > & operator*()
Definition: wrap/pybind11/include/pybind11/detail/common.h:1187
strip_function_object
Definition: wrap/pybind11/include/pybind11/detail/common.h:958
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:623
any_container::operator*
const std::vector< T > & operator*() const
Definition: wrap/pybind11/include/pybind11/detail/common.h:1188
exactly_one::index
static constexpr auto index
Definition: wrap/pybind11/include/pybind11/detail/common.h:880
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:593
PYBIND11_NAMESPACE
Definition: test_custom_type_casters.cpp:24
Eigen::Triplet< double >
test_call_policies.reason
reason
Definition: test_call_policies.py:10
error_scope::value
PyObject * value
Definition: wrap/pybind11/include/pybind11/detail/common.h:1090
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:639
pybind11_fail
PyExc_RuntimeError PYBIND11_NOINLINE void pybind11_fail(const char *reason)
Used internally.
Definition: wrap/pybind11/include/pybind11/detail/common.h:1026
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:490
set_error
void set_error(const handle &type, const char *message)
Definition: pytypes.h:346
silence_unused_warnings
void silence_unused_warnings(Args &&...)
Definition: wrap/pybind11/include/pybind11/detail/common.h:1222
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:677
deferred_type
Defer the evaluation of type T until types Us are instantiated.
Definition: wrap/pybind11/include/pybind11/detail/common.h:893
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:711
return_value_policy::take_ownership
@ take_ownership
nodelete::operator()
void operator()(T *)
Definition: wrap/pybind11/include/pybind11/detail/common.h:1100
last
constexpr int last(int, int result)
Definition: wrap/pybind11/include/pybind11/detail/common.h:843
overload_cast_impl::operator()
constexpr auto operator()(Return(*pf)(Args...)) const noexcept -> decltype(pf)
Definition: wrap/pybind11/include/pybind11/detail/common.h:1107
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:693
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:973
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:859
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:903
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:619
ssize_t_cast
ssize_t ssize_t_cast(const IntType &val)
Definition: wrap/pybind11/include/pybind11/detail/common.h:493
Class
Definition: testExpression.cpp:116
is_input_iterator
Check if T looks like an input iterator.
Definition: wrap/pybind11/include/pybind11/detail/common.h:946
std
Definition: BFloat16.h:88
void_type
Helper type to replace 'void' in some expressions.
Definition: wrap/pybind11/include/pybind11/detail/common.h:815
any_container::any_container
any_container(const std::initializer_list< TIn > &c)
Definition: wrap/pybind11/include/pybind11/detail/common.h:1176
error_scope::type
PyObject * type
Definition: wrap/pybind11/include/pybind11/detail/common.h:1090
instance::weakrefs
PyObject * weakrefs
Weak references.
Definition: wrap/pybind11/include/pybind11/detail/common.h:591
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:911
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:1112
void_t_impl
Definition: wrap/pybind11/include/pybind11/detail/common.h:723
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:349
nodelete
Dummy destructor wrapper that can be used to expose classes with a private destructor.
Definition: wrap/pybind11/include/pybind11/detail/common.h:1098
select_indices_impl
Make an index sequence of the indices of true arguments.
Definition: wrap/pybind11/include/pybind11/detail/common.h:698
N
#define N
Definition: igam.h:9
error_scope::~error_scope
~error_scope()
Definition: wrap/pybind11/include/pybind11/detail/common.h:1094
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:1044
builtin_exception
C++ bindings of builtin Python exceptions.
Definition: wrap/pybind11/include/pybind11/detail/common.h:998
constexpr_first
constexpr int constexpr_first()
Definition: wrap/pybind11/include/pybind11/detail/common.h:853
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:1180
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:654
is_template_base_of_impl::check
static std::true_type check(Base< Us... > *)
test_callbacks.value
value
Definition: test_callbacks.py:160
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:1142
remove_reference_t
typename std::remove_reference< T >::type remove_reference_t
Definition: wrap/pybind11/include/pybind11/detail/common.h:660
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:1118
S
DiscreteKey S(1, 2)
remove_cvref::type
remove_cv_t< remove_reference_t< T > > type
Definition: wrap/pybind11/include/pybind11/detail/common.h:669
any_container::any_container
any_container()=default


gtsam
Author(s):
autogenerated on Sat Nov 16 2024 04:01:59