Go to the documentation of this file.
27 #include <type_traits>
37 template <typename
type, typename SFINAE =
void>
39 template <
typename type>
54 template <
typename type>
65 "std::reference_wrapper<T> caster requires T to have a caster with an "
66 "`operator T &()` or `operator const T &()`");
82 explicit operator std::reference_wrapper<type>() {
return cast_op<type &>(subcaster); }
85 #define PYBIND11_TYPE_CASTER(type, py_name) \
90 static constexpr auto name = py_name; \
91 template <typename T_, \
92 ::pybind11::detail::enable_if_t< \
93 std::is_same<type, ::pybind11::detail::remove_cv_t<T_>>::value, \
96 static ::pybind11::handle cast( \
97 T_ *src, ::pybind11::return_value_policy policy, ::pybind11::handle parent) { \
99 return ::pybind11::none().release(); \
100 if (policy == ::pybind11::return_value_policy::take_ownership) { \
101 auto h = cast(std::move(*src), policy, parent); \
105 return cast(*src, policy, parent); \
107 operator type *() { return &value; } \
108 operator type &() { return value; } \
109 operator type &&() && { return std::move(value); } \
110 template <typename T_> \
111 using cast_op_type = ::pybind11::detail::movable_cast_op_type<T_>
113 template <
typename CharT>
115 #if defined(PYBIND11_HAS_U8STRING)
116 std::is_same<CharT, char8_t>,
118 std::is_same<CharT, char16_t>,
119 std::is_same<CharT, char32_t>,
120 std::is_same<CharT, wchar_t>
123 template <
typename T>
139 #if !defined(PYPY_VERSION)
140 auto index_check = [](PyObject *o) {
return PyIndex_Check(o); };
144 auto index_check = [](PyObject *o) {
return hasattr(o,
"__index__"); };
149 py_value = (
py_type) PyFloat_AsDouble(src.
ptr());
153 }
else if (PyFloat_Check(src.
ptr())
157 handle src_or_index = src;
159 #if PY_VERSION_HEX < 0x03080000 || defined(PYPY_VERSION)
162 index = reinterpret_steal<object>(PyNumber_Index(src.
ptr()));
168 src_or_index = index;
173 py_value = as_unsigned<py_type>(src_or_index.
ptr());
175 py_value =
sizeof(
T) <=
sizeof(
long)
182 bool py_err = py_value == (
py_type) -1 && PyErr_Occurred();
188 && py_value != (
py_type) (
T) py_value)) {
190 if (py_err &&
convert && (PyNumber_Check(src.
ptr()) != 0)) {
192 ? PyNumber_Float(src.
ptr())
193 : PyNumber_Long(src.
ptr()));
195 return load(tmp,
false);
204 template <
typename U = T>
207 return PyFloat_FromDouble((
double) src);
210 template <
typename U = T>
212 && (
sizeof(
U) <=
sizeof(
long)),
218 template <
typename U = T>
220 && (
sizeof(
U) <=
sizeof(
unsigned long)),
226 template <
typename U = T>
228 && (
sizeof(
U) >
sizeof(
long)),
231 return PyLong_FromLongLong((
long long) src);
234 template <
typename U = T>
236 && (
sizeof(
U) >
sizeof(
unsigned long)),
239 return PyLong_FromUnsignedLongLong((
unsigned long long) src);
245 template <
typename T>
249 if (src && src.is_none()) {
278 if (isinstance<capsule>(
h)) {
279 value = reinterpret_borrow<capsule>(
h);
285 if (bases.size() == 1) {
301 template <
typename T>
303 explicit operator void *&() {
return value; }
320 if (src.
ptr() == Py_True) {
324 if (src.
ptr() == Py_False) {
328 if (
convert || (std::strcmp(
"numpy.bool_", Py_TYPE(src.
ptr())->tp_name) == 0)) {
335 #if defined(PYPY_VERSION)
338 res = PyObject_IsTrue(src.
ptr());
343 else if (
auto *tp_as_number = src.
ptr()->ob_type->tp_as_number) {
349 if (
res == 0 ||
res == 1) {
364 template <
typename StringType,
bool IsView = false>
366 using CharT =
typename StringType::value_type;
371 "Unsupported char size != 1");
372 #if defined(PYBIND11_HAS_U8STRING)
374 "Unsupported char8_t size != 1");
377 "Unsupported char16_t size != 2");
379 "Unsupported char32_t size != 4");
382 "Unsupported wchar_t size != 2/4");
390 if (!PyUnicode_Check(load_src.
ptr())) {
397 Py_ssize_t
size = -1;
399 =
reinterpret_cast<const CharT *
>(PyUnicode_AsUTF8AndSize(load_src.
ptr(), &
size));
409 = reinterpret_steal<object>(PyUnicode_AsEncodedString(load_src.
ptr(),
411 :
UTF_N == 16 ?
"utf-16"
439 const char *
buffer =
reinterpret_cast<const char *
>(src.data());
452 #if !defined(PYPY_VERSION)
453 return UTF_N == 8 ? PyUnicode_DecodeUTF8(
buffer, nbytes,
nullptr)
454 :
UTF_N == 16 ? PyUnicode_DecodeUTF16(
buffer, nbytes,
nullptr,
nullptr)
455 : PyUnicode_DecodeUTF32(
buffer, nbytes,
nullptr,
nullptr);
460 return PyUnicode_Decode(
buffer,
463 :
UTF_N == 16 ?
"utf-16"
472 template <
typename C = CharT>
479 pybind11_fail(
"Unexpected PYBIND11_BYTES_AS_STRING() failure.");
484 if (PyByteArray_Check(src.ptr())) {
487 const char *
bytearray = PyByteArray_AsString(src.ptr());
491 value = StringType(
bytearray, (
size_t) PyByteArray_Size(src.ptr()));
498 template <
typename C = CharT>
504 template <
typename CharT,
class Traits,
class Allocator>
507 :
string_caster<std::basic_string<CharT, Traits, Allocator>> {};
509 #ifdef PYBIND11_HAS_STRING_VIEW
510 template <
typename CharT,
class Traits>
513 :
string_caster<std::basic_string_view<CharT, Traits>, true> {};
518 template <
typename CharT>
543 if (src ==
nullptr) {
544 return pybind11::none().release();
551 handle s = PyUnicode_DecodeLatin1((
const char *) &src, 1,
nullptr);
560 explicit operator CharT *() {
561 return none ? nullptr :
const_cast<CharT *
>(
static_cast<StringType &
>(str_caster).
c_str());
563 explicit operator CharT &() {
565 throw value_error(
"Cannot convert None to a character");
569 size_t str_len =
value.size();
571 throw value_error(
"Cannot convert empty string to a character");
579 if (StringCaster::UTF_N == 8 && str_len > 1 && str_len <= 4) {
580 auto v0 =
static_cast<unsigned char>(
value[0]);
585 size_t char0_bytes = (
v0 & 0x80) == 0 ? 1
586 : (
v0 & 0xE0) == 0xC0 ? 2
587 : (
v0 & 0xF0) == 0xE0 ? 3
590 if (char0_bytes == str_len) {
592 if (char0_bytes == 2 && (
v0 & 0xFC) == 0xC0) {
593 one_char =
static_cast<CharT
>(((
v0 & 3) << 6)
594 + (
static_cast<unsigned char>(
value[1]) & 0x3F));
598 throw value_error(
"Character code point not in range(0x100)");
605 else if (StringCaster::UTF_N == 16 && str_len == 2) {
606 one_char =
static_cast<CharT
>(
value[0]);
607 if (one_char >= 0xD800 && one_char < 0xE000) {
608 throw value_error(
"Character code point not in range(0x10000)");
613 throw value_error(
"Expected a character, but multi-character string found");
621 template <
typename _T>
626 template <
template <
typename...>
class Tuple,
typename... Ts>
629 static constexpr
auto size =
sizeof...(Ts);
634 if (!isinstance<sequence>(src)) {
637 const auto seq = reinterpret_borrow<sequence>(src);
644 template <
typename T>
650 template <
typename T>
656 auto h =
cast(std::move(*src), policy, parent);
660 return cast(*src, policy, parent);
663 static constexpr
auto name
666 template <
typename T>
670 explicit operator type() && {
return std::move(*this).implicit_cast(
indices{}); }
673 template <
size_t... Is>
677 template <
size_t... Is>
684 template <
size_t... Is>
686 #ifdef __cpp_fold_expressions
701 template <
typename T,
size_t... Is>
706 std::array<object, size> entries{{reinterpret_steal<object>(
708 for (
const auto &entry : entries) {
715 for (
auto &entry : entries) {
716 PyTuple_SET_ITEM(
result.ptr(), counter++, entry.release().ptr());
724 template <
typename T1,
typename T2>
727 template <
typename... Ts>
732 template <
typename T>
734 static auto get(
const T &
p) -> decltype(
p.get()) {
return p.get(); }
742 template <
typename type,
typename holder_type,
typename SFINAE =
void>
747 "Holder classes are only supported for custom types");
754 return base::template load_impl<copyable_holder_caster<type, holder_type>>(src,
convert);
761 explicit operator holder_type *() {
return std::addressof(
holder); }
762 explicit operator holder_type &() {
return holder; }
773 throw cast_error(
"Unable to load a custom holder type from a default-holder instance");
778 if (v_h.holder_constructed()) {
779 value = v_h.value_ptr();
780 holder = v_h.template holder<holder_type>();
783 throw cast_error(
"Unable to cast from non-held to held instance (T& to Holder<T>) "
785 "(#define PYBIND11_DETAILED_ERROR_MESSAGES or compile in debug mode for "
786 "type information)");
789 + type_id<holder_type>() +
"''");
793 template <
typename T = holder_type,
799 template <
typename T = holder_type,
819 template <
typename T>
825 template <
typename type,
typename holder_type,
typename SFINAE =
void>
828 "Holder classes are only supported for custom types");
837 template <
typename type,
typename deleter>
841 template <
typename type,
typename holder_type>
846 template <
typename T,
bool Value = false>
848 static constexpr
bool value = Value;
852 #define PYBIND11_DECLARE_HOLDER_TYPE(type, holder_type, ...) \
853 PYBIND11_NAMESPACE_BEGIN(PYBIND11_NAMESPACE) \
855 template <typename type> \
856 struct always_construct_holder<holder_type> : always_construct_holder<void, ##__VA_ARGS__> { \
858 template <typename type> \
859 class type_caster<holder_type, enable_if_t<!is_shared_ptr<holder_type>::value>> \
860 : public type_caster_holder<type, holder_type> {}; \
862 PYBIND11_NAMESPACE_END(PYBIND11_NAMESPACE)
865 template <
typename base,
typename holder>
867 : std::is_base_of<detail::type_caster_holder<base, holder>, detail::type_caster<holder>> {};
869 template <
typename base,
typename deleter>
872 template <
typename T>
874 static constexpr
auto name = const_name<T>();
913 template <
typename type>
926 return static_cast<bool>(
value);
931 if (!isinstance<type>(src)) {
934 value = reinterpret_borrow<type>(src);
944 template <
typename T>
956 template <
typename T>
959 template <
typename T,
typename SFINAE =
void>
961 template <
typename T>
968 std::is_same<decltype(std::declval<make_caster<T>>().operator T &()), T &>>
::value>>
970 template <
typename T,
typename SFINAE =
void>
972 template <
typename T>
979 std::is_same<decltype(std::declval<make_caster<T>>().operator T &()), T &>>
::value>>
981 template <
typename T>
988 template <
typename type>
997 template <
typename Return,
typename SFINAE =
void>
1002 template <
typename Return>
1005 detail::
enable_if_t<std::is_base_of<type_caster_generic, make_caster<Return>>::value, void>> {
1014 template <
typename T,
typename SFINAE>
1017 "Internal error: type_caster should only be used for C++ types");
1019 #if !defined(PYBIND11_DETAILED_ERROR_MESSAGES)
1021 "Unable to cast Python instance of type "
1023 +
" to C++ type '?' (#define "
1024 "PYBIND11_DETAILED_ERROR_MESSAGES or compile in debug mode for details)");
1026 throw cast_error(
"Unable to cast Python instance of type "
1028 + type_id<T>() +
"'");
1034 template <
typename T>
1044 template <
typename T,
1052 "Unable to cast type to reference: value is local to type caster");
1053 return cast_op<T>(load_type<T>(
handle));
1059 return T(reinterpret_borrow<object>(
handle));
1070 template <
typename T,
1080 template <
typename T,
1087 return obj.release().ptr();
1105 return reinterpret_steal<object>(
1109 template <
typename T>
1111 return pybind11::cast<T>(*
this);
1118 template <
typename T>
1120 if (obj.ref_count() > 1) {
1121 #if !defined(PYBIND11_DETAILED_ERROR_MESSAGES)
1124 +
" instance to C++ rvalue: instance has multiple references"
1125 " (#define PYBIND11_DETAILED_ERROR_MESSAGES or compile in debug mode for details)");
1127 throw cast_error(
"Unable to move from Python "
1129 + type_id<T>() +
" instance: instance has multiple references");
1134 T ret = std::move(detail::load_type<T>(obj).
operator T &());
1143 template <
typename T>
1146 return move<T>(std::move(
object));
1148 template <
typename T>
1151 if (
object.ref_count() > 1) {
1152 return cast<T>(
object);
1154 return move<T>(std::move(
object));
1156 template <
typename T>
1159 return cast<T>(
object);
1163 template <
typename T>
1165 return T(std::move(
object));
1168 template <
typename T>
1170 return pybind11::cast<T>(*
this);
1172 template <
typename T>
1174 return pybind11::cast<T>(std::move(*
this));
1196 template <
typename ret_type>
1203 template <
typename T>
1206 return cast_op<T>(
load_type(caster, o));
1208 template <
typename T>
1217 template <
typename T>
1219 pybind11_fail(
"Internal error: cast_safe fallback invoked");
1221 template <
typename T>
1223 template <
typename T>
1226 return pybind11::cast<T>(std::move(o));
1233 #if !defined(PYBIND11_DETAILED_ERROR_MESSAGES)
1235 return cast_error(
"Unable to convert call argument '" +
name
1236 +
"' to Python object (#define "
1237 "PYBIND11_DETAILED_ERROR_MESSAGES or compile in debug mode for details)");
1241 const std::string &
type) {
1242 return cast_error(
"Unable to convert call argument '" +
name +
"' of type '" +
type
1243 +
"' to Python object");
1247 template <return_value_policy policy = return_value_policy::automatic_reference>
1254 constexpr
size_t size =
sizeof...(Args);
1255 std::array<object, size>
args{{reinterpret_steal<object>(
1259 #if !defined(PYBIND11_DETAILED_ERROR_MESSAGES)
1262 std::array<std::string, size> argtypes{{type_id<Args>()...}};
1269 for (
auto &arg_value :
args) {
1270 PyTuple_SET_ITEM(
result.ptr(), counter++, arg_value.release().ptr());
1280 constexpr
explicit arg(
const char *
name =
nullptr)
1283 template <
typename T>
1306 template <
typename T>
1311 #if defined(PYBIND11_DETAILED_ERROR_MESSAGES)
1319 if (PyErr_Occurred()) {
1326 template <
typename T>
1331 template <
typename T>
1351 #if defined(PYBIND11_DETAILED_ERROR_MESSAGES)
1367 template <
typename T>
1369 return {*
this, std::forward<T>(
value)};
1373 template <
typename >
1385 template <
typename T>
1387 template <
typename T>
1418 template <
typename... Args>
1422 template <
typename Arg>
1424 template <
typename Arg>
1430 "py::kwargs is only permitted as the last argument of a function");
1438 static_assert(
args_pos == -1 ||
args_pos == constexpr_first<argument_is_args, Args...>(),
1439 "py::args cannot be specified more than once");
1445 template <
typename Return,
typename Guard,
typename Func>
1449 std::forward<Func>(
f),
indices{}, Guard{});
1452 template <
typename Return,
typename Guard,
typename Func>
1455 std::forward<Func>(
f),
indices{}, Guard{});
1462 template <
size_t... Is>
1464 #ifdef __cpp_fold_expressions
1469 for (
bool r : {std::get<Is>(
argcasters).load(
call.args[Is],
call.args_convert[Is])...}) {
1478 template <
typename Return,
typename Func,
size_t... Is,
typename Guard>
1480 return std::forward<Func>(
f)(cast_op<Args>(std::move(std::get<Is>(
argcasters)))...);
1488 template <return_value_policy policy>
1491 template <
typename... Ts>
1506 return reinterpret_steal<object>(
result);
1514 template <return_value_policy policy>
1517 template <
typename... Ts>
1521 auto args_list = list();
1522 using expander =
int[];
1523 (void) expander{0, (
process(args_list, std::forward<Ts>(
values)), 0)...};
1525 m_args = std::move(args_list);
1540 return reinterpret_steal<object>(
result);
1544 template <
typename T>
1546 auto o = reinterpret_steal<object>(
1549 #if !defined(PYBIND11_DETAILED_ERROR_MESSAGES)
1556 args_list.append(std::move(o));
1559 void process(list &args_list, detail::args_proxy ap) {
1561 args_list.append(
a);
1567 #if !defined(PYBIND11_DETAILED_ERROR_MESSAGES)
1574 #if !defined(PYBIND11_DETAILED_ERROR_MESSAGES)
1581 #if !defined(PYBIND11_DETAILED_ERROR_MESSAGES)
1594 for (
auto k : reinterpret_borrow<dict>(kp)) {
1596 #if !defined(PYBIND11_DETAILED_ERROR_MESSAGES)
1608 "Got kwargs without a name; only named arguments "
1609 "may be passed via py::arg() to a python function call. "
1610 "(#define PYBIND11_DETAILED_ERROR_MESSAGES or compile in debug mode for details)");
1613 throw type_error(
"Got kwargs without a name of type '" +
type
1615 "arguments may be passed via py::arg() to a python function call. ");
1619 "Got multiple values for keyword argument "
1620 "(#define PYBIND11_DETAILED_ERROR_MESSAGES or compile in debug mode for details)");
1624 throw type_error(
"Got multiple values for keyword argument '" +
name +
"'");
1636 template <
typename... Args>
1655 static_assert(constexpr_last<is_positional, Args...>()
1656 < constexpr_first<is_keyword_or_ds, Args...>()
1657 && constexpr_last<is_s_unpacking, Args...>()
1658 < constexpr_first<is_ds_unpacking, Args...>(),
1659 "Invalid function call: positional args must precede keywords and ** unpacking; "
1660 "* unpacking must precede ** unpacking");
1664 template <
typename Derived>
1668 if (!PyGILState_Check()) {
1669 pybind11_fail(
"pybind11::object_api<>::operator() PyGILState_Check() failure.");
1672 return detail::collect_arguments<policy>(std::forward<Args>(
args)...).call(derived().ptr());
1675 template <
typename Derived>
1677 object object_api<Derived>::call(Args &&...
args)
const {
1678 return operator()<policy>(std::forward<Args>(
args)...);
1683 template <
typename T>
1685 static_assert(std::is_base_of<detail::type_caster_generic, detail::make_caster<T>>::
value,
1686 "py::type::of<T> only supports the case where T is a registered C++ types.");
1691 #define PYBIND11_MAKE_OPAQUE(...) \
1692 PYBIND11_NAMESPACE_BEGIN(PYBIND11_NAMESPACE) \
1693 namespace detail { \
1695 class type_caster<__VA_ARGS__> : public type_caster_base<__VA_ARGS__> {}; \
1697 PYBIND11_NAMESPACE_END(PYBIND11_NAMESPACE)
1702 #define PYBIND11_TYPE(...) __VA_ARGS__
static handle cast(T *src, return_value_policy policy, handle parent)
type_caster< T, SFINAE > & load_type(type_caster< T, SFINAE > &conv, const handle &handle)
#define PYBIND11_BYTES_SIZE
std::is_same< bools< Ts::value..., true >, bools< true, Ts::value... > > all_of
PyObject * conv(PyObject *o)
static std::enable_if<!std::is_floating_point< U >::value &&std::is_unsigned< U >::value &&(sizeof(U)<=sizeof(unsigned long)), handle >::type cast(U src, return_value_policy, handle)
void process(list &args_list, T &&x)
Annotation for function names.
T cast(const handle &handle)
static constexpr size_t UTF_N
Annotation indicating that a class derives from another given type.
static handle cast(const void *ptr, return_value_policy, handle)
bool load_args(function_call &call)
constexpr arg(const char *name=nullptr)
static handle cast(bool src, return_value_policy, handle)
constexpr descr< N - 1 > const_name(char const (&text)[N])
static handle cast(CharT src, return_value_policy policy, handle parent)
return_value_policy
Approach used to cast a previously unknown C++ instance into a Python object.
bool load(handle src, bool)
std::vector< std::pair< const std::type_info *, void *(*)(void *)> > implicit_casts
static handle cast(const holder_type &src, return_value_policy, handle)
typename std::remove_cv< T >::type remove_cv_t
enable_if_t<!std::is_void< Return >::value, Return > call(Func &&f) &&
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy x
const handle & inc_ref() const &
const function_record & func
The function data:
static return_value_policy policy(return_value_policy p)
std::is_same< intrinsic_t< Arg >, args > argument_is_args
std::basic_string< CharT > StringType
#define PYBIND11_NAMESPACE_END(name)
static void multiple_values_error(const std::string &name)
bool hasattr(handle obj, handle name)
static handle cast(holder_type &&src, return_value_policy, handle)
arg_v(arg &&base, T &&x, const char *descr=nullptr)
conditional_t< std::is_signed< T >::value, _py_type_0, typename std::make_unsigned< _py_type_0 >::type > _py_type_1
Eigen::Triplet< double > T
object operator()(Args &&...args) const
bool load_impl_sequence(function_call &call, index_sequence< Is... >)
static constexpr auto arg_names
static handle cast(const CharT *src, return_value_policy policy, handle parent)
enable_if_t< cast_is_temporary_value_reference< T >::value, T > cast_ref(object &&o, make_caster< T > &caster)
function_call(const function_record &f, handle p)
static std::enable_if<!std::is_floating_point< U >::value &&std::is_signed< U >::value &&(sizeof(U)<=sizeof(long)), handle >::type cast(U src, return_value_policy, handle)
#define PYBIND11_NAMESPACE_BEGIN(name)
simple_collector< policy > collect_arguments(Args &&...args)
Collect only positional arguments for a Python function call.
cout<< "Here is the matrix m:"<< endl<< m<< endl;Matrix< ptrdiff_t, 3, 1 > res
arg_v operator=(T &&value) const
Assign a value to this argument.
const std::vector< detail::type_info * > & all_type_info(PyTypeObject *type)
static handle cast_impl(T &&src, return_value_policy policy, handle parent, index_sequence< Is... >)
std::reference_wrapper< type > cast_op_type
static handle cast(const StringType &src, return_value_policy, handle)
enable_if_t< std::is_void< Return >::value, void_type > call(Func &&f) &&
static bool try_direct_conversions(handle)
bool load(handle src, bool convert)
#define PYBIND11_LONG_AS_LONGLONG(o)
type implicit_cast(index_sequence< Is... >) &&
handle parent
The parent, if any.
typename std::conditional< B, T, F >::type conditional_t
The 'instance' type which needs to be standard layout (need to be able to use 'offsetof')
Internal data associated with a single function call.
bool load(handle src, bool convert)
simple_collector(Ts &&...values)
std::is_same< intrinsic_t< T >, pos_only > is_pos_only
void process(list &, detail::kwargs_proxy kp)
std::string type
The C++ type name of the default value (only available when compiled in debug mode)
static constexpr bool value
static handle cast(const itype &src, return_value_policy policy, handle parent)
void check_holder_compat()
object call(PyObject *ptr) const
Call a Python function and pass the collected arguments.
std::is_same< intrinsic_t< T >, kw_only > is_kw_only
const char * name
If non-null, this is a named kwargs argument.
Reference counted object base class.
const tuple & args() const &
PYBIND11_TYPE_CASTER(type, handle_type_name< type >::name)
#define PYBIND11_LONG_CHECK(o)
arg_v(const char *name, T &&x, const char *descr=nullptr)
Direct construction with name, default, and description.
PYBIND11_TYPE_CASTER(StringType, const_name(PYBIND11_STRING_NAME))
PYBIND11_TYPE_CASTER(T, const_name("None"))
bool load(handle src, bool convert)
typename intrinsic_type< T >::type intrinsic_t
conditional_t< cast_is_temporary_value_reference< ret_type >::value, make_caster< ret_type >, override_unused > override_caster_t
conditional_t< std::is_floating_point< T >::value, double, _py_type_1 > py_type
object value
The default value.
static handle handle_of()
handle init_self
If this is a call to an initializer, this argument contains self
static return_value_policy policy(return_value_policy p)
bool_constant<(std::is_reference< type >::value||std::is_pointer< type >::value) &&!std::is_base_of< type_caster_generic, make_caster< type > >::value &&!std::is_same< intrinsic_t< type >, void >::value > cast_is_temporary_value_reference
static handle cast(T, return_value_policy, handle)
bool load(handle src, bool convert)
static std::enable_if<!std::is_floating_point< U >::value &&std::is_unsigned< U >::value &&(sizeof(U) > sizeof(unsigned long)), handle >::type cast(U src, return_value_policy, handle)
#define PYBIND11_DETAILED_ERROR_MESSAGES
Tuple< make_caster< Ts >... > subcasters
typename caster_t::template cast_op_type< reference_t > subcaster_cast_op_type
bool load(handle src, bool)
void process(list &args_list, detail::args_proxy ap)
bool flag_none
If set (the default), allow None to be passed to this argument.
unpacking_collector(Ts &&...values)
const dict & kwargs() const &
bool load(handle src, bool convert)
Return call_impl(Func &&f, index_sequence< Is... >, Guard &&) &&
cast_error cast_error_unable_to_convert_call_arg(const std::string &name, const std::string &type)
constexpr descr< 0 > concat()
EIGEN_DEVICE_FUNC const EIGEN_STRONG_INLINE ArgReturnType arg() const
enable_if_t< cast_is_temporary_value_reference< T >::value, T > cast_safe(object &&)
PyExc_RuntimeError PYBIND11_NOINLINE void pybind11_fail(const char *reason)
Used internally.
make_index_sequence< sizeof...(Args)> indices
static constexpr int args_pos
bool load(handle h, bool)
static void nameless_argument_error(const std::string &type)
arg_v & noconvert(bool flag=true)
Same as arg::noconvert(), but returns *this as arg_v&, not arg&.
conditional_t< std::is_pointer< remove_reference_t< T > >::value, typename std::add_pointer< intrinsic_t< T > >::type, typename std::add_lvalue_reference< intrinsic_t< T > >::type > cast_op_type
constexpr descr< N+2, Ts... > type_descr(const descr< N, Ts... > &descr)
static constexpr auto kwargs_pos
#define PYBIND11_BYTES_NAME
Point2(* f)(const Point3 &, OptionalJacobian< 2, 3 >)
#define PYBIND11_BOOL_ATTR
make_index_sequence< size > indices
#define PYBIND11_TYPE_CASTER(type, py_name)
std::integral_constant< bool, B > bool_constant
Backports of std::bool_constant and std::negation to accommodate older compilers.
static void multiple_values_error()
bool load_value(value_and_holder &&v_h)
static handle cast(const std::reference_wrapper< type > &src, return_value_policy policy, handle parent)
arg & none(bool flag=true)
Indicates that the argument should/shouldn't allow None (e.g. for nullable pointer args)
Helper class which collects positional, keyword, * and ** arguments for a Python function call.
const char * descr
The (optional) description of the default value.
#define PYBIND11_BYTES_AS_STRING
detail::enable_if_t<!detail::move_never< T >::value, T > move(object &&obj)
#define PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(...)
bool load_raw(enable_if_t< std::is_same< C, char >::value, handle > src)
typename make_index_sequence_impl< N >::type make_index_sequence
bool contains(T &&key) const
PyObject * ptr() const
Return the underlying PyObject * pointer.
constexpr int constexpr_last()
Return the index of the last type in Ts which satisfies Predicate<T>, or -1 if none match.
PYBIND11_WARNING_PUSH PYBIND11_WARNING_DISABLE_MSVC(5054) PYBIND11_WARNING_POP static_assert(EIGEN_VERSION_AT_LEAST(3
std::is_same< intrinsic_t< Arg >, kwargs > argument_is_kwargs
static constexpr bool load_impl(const sequence &, bool, index_sequence<>)
conditional_t< is_copy_constructible< holder_type >::value, copyable_holder_caster< type, holder_type >, move_only_holder_caster< type, holder_type > > type_caster_holder
static bool load_impl_sequence(function_call &, index_sequence<>)
Helper class which loads arguments for C++ functions called from Python.
bool try_implicit_casts(handle, bool)
pybind11::detail::cast_op_type< _T > cast_op_type
PYBIND11_NOINLINE handle get_type_handle(const std::type_info &tp, bool throw_if_missing)
static constexpr auto size
Helper type to replace 'void' in some expressions.
object call(PyObject *ptr) const
Call a Python function and pass the collected arguments.
static void nameless_argument_error()
const char * c_str(Args &&...args)
std::tuple< make_caster< Args >... > argcasters
static auto get(const T &p) -> decltype(p.get())
std::is_base_of< pyobject_tag, remove_reference_t< T > > is_pyobject
bool load_impl(const sequence &seq, bool convert, index_sequence< Is... >)
#define PYBIND11_NB_BOOL(ptr)
make_caster< T >::template cast_op_type< T > cast_op(make_caster< T > &caster)
static handle decode_utfN(const char *buffer, ssize_t nbytes)
void process(list &, arg_v a)
bool load(handle src, bool convert)
static std::enable_if< std::is_floating_point< U >::value, handle >::type cast(U src, return_value_policy, handle)
const type_info * typeinfo
#define PYBIND11_WORKAROUND_INCORRECT_GCC_UNUSED_BUT_SET_PARAMETER(...)
bool load(handle src, bool convert)
std::vector< handle > args
Arguments passed to the function:
object object_or_cast(T &&o)
static handle cast_holder(const itype *src, const void *holder)
static handle cast(const handle &src, return_value_policy, handle)
conditional_t< sizeof(T)<=sizeof(long), long, long long > _py_type_0
static std::enable_if<!std::is_floating_point< U >::value &&std::is_signed< U >::value &&(sizeof(U) > sizeof(long)), handle >::type cast(U src, return_value_policy, handle)
arg & noconvert(bool flag=true)
Indicate that the type should not be converted in the type caster.
#define PYBIND11_LONG_FROM_SIGNED(o)
bool try_implicit_casts(handle src, bool convert)
const tuple & args() const &
type implicit_cast(index_sequence< Is... >) &
T reinterpret_steal(handle h)
static BinaryMeasurement< Rot3 > convert(const BetweenFactor< Pose3 >::shared_ptr &f)
#define PYBIND11_STRING_NAME
static constexpr bool has_kwargs
internal::enable_if<!(symbolic::is_symbolic< FirstType >::value||symbolic::is_symbolic< LastType >::value), ArithmeticSequence< typename internal::cleanup_index_type< FirstType >::type, Index > >::type seq(FirstType f, LastType l)
#define PYBIND11_BYTES_CHECK
typename std::enable_if< B, T >::type enable_if_t
from cpp_future import (convenient aliases from C++14/17)
#define PYBIND11_LONG_FROM_UNSIGNED(o)
arg_v(const arg &base, T &&x, const char *descr=nullptr)
Called internally when invoking py::arg("a") = value
static PYBIND11_NOINLINE void add_patient(handle h)
std::vector< bool > args_convert
The convert value the arguments should be loaded with.
typename std::basic_string< CharT, Traits, Allocator > ::value_type CharT
constexpr bool args_are_all_positional()
static handle cast(T &&src, return_value_policy policy, handle parent)
arg_v & none(bool flag=true)
Same as arg::nonone(), but returns *this as arg_v&, not arg&.
bool load(handle src, bool)
bool load_raw(enable_if_t<!std::is_same< C, char >::value, handle >)
Generic type caster for objects stored on the heap.
gtsam
Author(s):
autogenerated on Sat Jun 1 2024 03:01:17