Go to the documentation of this file.
16 #include <type_traits>
18 template <
typename derived>
150 return cast(*src, policy, parent);
154 template <
typename T>
169 py::class_<lacking_copy_ctor>(
m,
"lacking_copy_ctor")
172 py::class_<lacking_move_ctor>(
m,
"lacking_move_ctor")
177 m.def(
"move_and_copy_casts", [](
const py::object &o) {
179 r += py::cast<MoveOrCopyInt>(o).value;
180 r += py::cast<MoveOnlyInt>(o).value;
181 r += py::cast<CopyOnlyInt>(o).value;
182 auto m1(py::cast<MoveOrCopyInt>(o));
183 auto m2(py::cast<MoveOnlyInt>(o));
184 auto m3(py::cast<CopyOnlyInt>(o));
185 r +=
m1.value +
m2.value +
m3.value;
199 [](std::pair<MoveOnlyInt, MoveOrCopyInt>
p) {
return p.first.value +
p.second.value; });
200 m.def(
"move_tuple", [](std::tuple<MoveOnlyInt, MoveOrCopyInt, MoveOnlyInt>
t) {
201 return std::get<0>(
t).value + std::get<1>(
t).value + std::get<2>(
t).value;
203 m.def(
"copy_tuple", [](std::tuple<CopyOnlyInt, CopyOnlyInt>
t) {
204 return std::get<0>(
t).value + std::get<1>(
t).value;
206 m.def(
"move_copy_nested",
210 return x.first.value + std::get<0>(
x.second.first).value
211 + std::get<1>(
x.second.first).value
212 + std::get<0>(std::get<2>(
x.second.first)).value +
x.second.second.value;
214 m.def(
"move_and_copy_cstats", []() {
217 auto &mc = ConstructorStats::get<MoveOrCopyInt>();
218 mc.move_assignments = mc.move_constructions = mc.copy_assignments = mc.copy_constructions
220 auto &mo = ConstructorStats::get<MoveOnlyInt>();
221 mo.move_assignments = mo.move_constructions = mo.copy_assignments = mo.copy_constructions
223 auto &co = ConstructorStats::get<CopyOnlyInt>();
224 co.move_assignments = co.move_constructions = co.copy_assignments = co.copy_constructions
227 d[
"MoveOrCopyInt"] =
py::cast(mc, py::return_value_policy::reference);
228 d[
"MoveOnlyInt"] =
py::cast(mo, py::return_value_policy::reference);
229 d[
"CopyOnlyInt"] =
py::cast(co, py::return_value_policy::reference);
232 #ifdef PYBIND11_HAS_OPTIONAL
234 m.attr(
"has_optional") =
true;
235 m.def(
"move_optional", [](std::optional<MoveOnlyInt> o) {
return o->value; });
236 m.def(
"move_or_copy_optional", [](std::optional<MoveOrCopyInt> o) {
return o->value; });
237 m.def(
"copy_optional", [](std::optional<CopyOnlyInt> o) {
return o->value; });
238 m.def(
"move_optional_tuple",
239 [](std::optional<std::tuple<MoveOrCopyInt, MoveOnlyInt, CopyOnlyInt>>
x) {
240 return std::get<0>(*x).value + std::get<1>(*x).value + std::get<2>(*x).value;
243 m.attr(
"has_optional") =
false;
250 struct PrivateOpNew {
254 void *
operator new(
size_t bytes) {
255 void *ptr = std::malloc(
bytes);
259 throw std::bad_alloc{};
263 m.def(
"private_op_new_value", []() {
return PrivateOpNew(); });
265 "private_op_new_reference",
266 []() ->
const PrivateOpNew & {
267 static PrivateOpNew
x{};
270 py::return_value_policy::reference);
276 explicit MoveIssue1(
int v) :
v{
v} {}
277 MoveIssue1(
const MoveIssue1 &
c) =
default;
278 MoveIssue1(MoveIssue1 &&) =
delete;
280 py::class_<MoveIssue1>(
m,
"MoveIssue1")
281 .def(py::init<int>())
286 explicit MoveIssue2(
int v) :
v{
v} {}
287 MoveIssue2(MoveIssue2 &&) =
default;
289 py::class_<MoveIssue2>(
m,
"MoveIssue2")
290 .def(py::init<int>())
297 [](
int i) {
return std::unique_ptr<MoveIssue1>(
new MoveIssue1(
i)); },
302 m.def(
"get_pytype_rvalue_castissue", [](
double i) {
return py::float_(
i).cast<py::int_>(); });
304 py::class_<UnusualOpRef>(
m,
"UnusualOpRef");
305 m.def(
"CallCastUnusualOpRefConstRef",
306 []() {
return CastUnusualOpRefConstRef(
UnusualOpRef()); });
307 m.def(
"CallCastUnusualOpRefMovable", []() {
return CastUnusualOpRefMovable(
UnusualOpRef()); });
327 "!std::is_move_constructible<NotMovable>::value");
329 "std::is_copy_constructible<NotMovable>::value");
331 "!pybind11::detail::is_move_constructible<NotMovable>::value");
333 "pybind11::detail::is_copy_constructible<NotMovable>::value");
335 "!std::is_move_assignable<NotMovable>::value");
337 "std::is_copy_assignable<NotMovable>::value");
342 "pybind11::detail::is_copy_assignable<NotMovable>::value");
352 "std::is_move_constructible<NotCopyable>::value");
354 "!std::is_copy_constructible<NotCopyable>::value");
356 "pybind11::detail::is_move_constructible<NotCopyable>::value");
358 "!pybind11::detail::is_copy_constructible<NotCopyable>::value");
360 "std::is_move_assignable<NotCopyable>::value");
362 "!std::is_copy_assignable<NotCopyable>::value");
367 "!pybind11::detail::is_copy_assignable<NotCopyable>::value");
377 "!std::is_move_constructible<NotCopyableNotMovable>::value");
379 "!std::is_copy_constructible<NotCopyableNotMovable>::value");
381 "!pybind11::detail::is_move_constructible<NotCopyableNotMovable>::value");
383 "!pybind11::detail::is_copy_constructible<NotCopyableNotMovable>::value");
385 "!std::is_move_assignable<NotCopyableNotMovable>::value");
387 "!std::is_copy_assignable<NotCopyableNotMovable>::value");
392 "!pybind11::detail::is_copy_assignable<NotCopyableNotMovable>::value");
396 "std::is_move_constructible<NotMovableVector>::value");
398 "std::is_copy_constructible<NotMovableVector>::value");
400 "!pybind11::detail::is_move_constructible<NotMovableVector>::value");
402 "pybind11::detail::is_copy_constructible<NotMovableVector>::value");
404 "std::is_move_assignable<NotMovableVector>::value");
406 "std::is_copy_assignable<NotMovableVector>::value");
411 "pybind11::detail::is_copy_assignable<NotMovableVector>::value");
415 "std::is_move_constructible<NotCopyableVector>::value");
417 "std::is_copy_constructible<NotCopyableVector>::value");
419 "pybind11::detail::is_move_constructible<NotCopyableVector>::value");
421 "!pybind11::detail::is_copy_constructible<NotCopyableVector>::value");
423 "std::is_move_assignable<NotCopyableVector>::value");
425 "std::is_copy_assignable<NotCopyableVector>::value");
430 "!pybind11::detail::is_copy_assignable<NotCopyableVector>::value");
434 "std::is_move_constructible<NotCopyableNotMovableVector>::value");
436 "std::is_copy_constructible<NotCopyableNotMovableVector>::value");
438 "!pybind11::detail::is_move_constructible<NotCopyableNotMovableVector>::value");
440 "!pybind11::detail::is_copy_constructible<NotCopyableNotMovableVector>::value");
442 "std::is_move_assignable<NotCopyableNotMovableVector>::value");
444 "std::is_copy_assignable<NotCopyableNotMovableVector>::value");
449 "!pybind11::detail::is_copy_assignable<NotCopyableNotMovableVector>::value");
453 "std::is_move_constructible<NotMovableMap>::value");
455 "std::is_copy_constructible<NotMovableMap>::value");
457 "!pybind11::detail::is_move_constructible<NotMovableMap>::value");
459 "pybind11::detail::is_copy_constructible<NotMovableMap>::value");
461 "std::is_move_assignable<NotMovableMap>::value");
463 "std::is_copy_assignable<NotMovableMap>::value");
468 "pybind11::detail::is_copy_assignable<NotMovableMap>::value");
472 "std::is_move_constructible<NotCopyableMap>::value");
474 "std::is_copy_constructible<NotCopyableMap>::value");
476 "pybind11::detail::is_move_constructible<NotCopyableMap>::value");
478 "!pybind11::detail::is_copy_constructible<NotCopyableMap>::value");
480 "std::is_move_assignable<NotCopyableMap>::value");
482 "std::is_copy_assignable<NotCopyableMap>::value");
487 "!pybind11::detail::is_copy_assignable<NotCopyableMap>::value");
491 "std::is_move_constructible<NotCopyableNotMovableMap>::value");
493 "std::is_copy_constructible<NotCopyableNotMovableMap>::value");
495 "!pybind11::detail::is_move_constructible<NotCopyableNotMovableMap>::value");
497 "!pybind11::detail::is_copy_constructible<NotCopyableNotMovableMap>::value");
499 "std::is_move_assignable<NotCopyableNotMovableMap>::value");
501 "std::is_copy_assignable<NotCopyableNotMovableMap>::value");
506 "!pybind11::detail::is_copy_assignable<NotCopyableNotMovableMap>::value");
510 "std::is_move_constructible<RecursiveVector>::value");
512 "std::is_copy_constructible<RecursiveVector>::value");
514 "pybind11::detail::is_move_constructible<RecursiveVector>::value");
516 "pybind11::detail::is_copy_constructible<RecursiveVector>::value");
518 "std::is_move_assignable<RecursiveVector>::value");
520 "std::is_copy_assignable<RecursiveVector>::value");
525 "pybind11::detail::is_copy_assignable<RecursiveVector>::value");
529 "std::is_move_constructible<RecursiveMap>::value");
531 "std::is_copy_constructible<RecursiveMap>::value");
533 "pybind11::detail::is_move_constructible<RecursiveMap>::value");
535 "pybind11::detail::is_copy_constructible<RecursiveMap>::value");
537 "std::is_move_assignable<RecursiveMap>::value");
539 "std::is_copy_assignable<RecursiveMap>::value");
544 "pybind11::detail::is_copy_assignable<RecursiveMap>::value");
Annotation for function names.
static handle cast(const CopyOnlyInt *src, return_value_policy policy, handle parent)
static handle cast(const CopyOnlyInt &m, return_value_policy r, handle p)
constexpr descr< N - 1 > const_name(char const (&text)[N])
static const double d[K][N]
return_value_policy
Approach used to cast a previously unknown C++ instance into a Python object.
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
NotMovable & operator=(NotMovable const &)=default
#define PYBIND11_NAMESPACE_END(name)
int EIGEN_BLAS_FUNC() copy(int *n, RealScalar *px, int *incx, RealScalar *py, int *incy)
#define PYBIND11_NAMESPACE_BEGIN(name)
pybind11::detail::cast_op_type< T > cast_op_type
NotCopyable & operator=(NotCopyable const &)=delete
void print_copy_created(T *inst, Values &&...values)
void print_default_created(T *inst, Values &&...values)
bool load(handle src, bool)
static handle cast(const itype &src, return_value_policy policy, handle parent)
NotCopyableNotMovable & operator=(NotCopyableNotMovable const &)=delete
MoveOrCopyInt(const MoveOrCopyInt &c)
void print_copy_assigned(T *inst, Values &&...values)
lacking_move_ctor()=default
void swap(GeographicLib::NearestNeighbor< dist_t, pos_t, distfun_t > &a, GeographicLib::NearestNeighbor< dist_t, pos_t, distfun_t > &b)
CopyOnlyInt(const CopyOnlyInt &c)
MoveOrCopyInt & operator=(const MoveOrCopyInt &c)
TEST_SUBMODULE(copy_move_policies, m)
static const derived & get_one()
#define PYBIND11_TYPE_CASTER(type, py_name)
static const DiscreteKey m3(M(3), 2)
detail::enable_if_t<!detail::move_never< T >::value, T > move(object &&obj)
static handle cast(const MoveOrCopyInt &m, return_value_policy r, handle p)
MoveOnlyInt & operator=(MoveOnlyInt &&m) noexcept
bool load(handle src, bool)
void print_move_created(T *inst, Values &&...values)
MoveOrCopyInt(MoveOrCopyInt &&m) noexcept
void print_destroyed(T *inst, Values &&...values)
static handle cast(const MoveOnlyInt &m, return_value_policy r, handle p)
NotCopyableNotMovable()=default
CopyOnlyInt & operator=(const CopyOnlyInt &c)
Array< int, Dynamic, 1 > v
void print_move_assigned(T *inst, Values &&...values)
lacking_copy_ctor()=default
bool load(handle src, bool)
EIGEN_DEVICE_FUNC NewType cast(const OldType &x)
MoveOrCopyInt & operator=(MoveOrCopyInt &&m) noexcept
void print_created(T *inst, Values &&...values)
MoveOnlyInt(MoveOnlyInt &&m) noexcept
gtsam
Author(s):
autogenerated on Sun Dec 22 2024 04:15:58