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>
162 py::class_<lacking_copy_ctor>(
m,
"lacking_copy_ctor")
165 py::class_<lacking_move_ctor>(
m,
"lacking_move_ctor")
170 m.def(
"move_and_copy_casts", [](
const py::object &o) {
172 r += py::cast<MoveOrCopyInt>(o).value;
173 r += py::cast<MoveOnlyInt>(o).value;
174 r += py::cast<CopyOnlyInt>(o).value;
175 auto m1(py::cast<MoveOrCopyInt>(o));
176 auto m2(py::cast<MoveOnlyInt>(o));
177 auto m3(py::cast<CopyOnlyInt>(o));
178 r +=
m1.value +
m2.value + m3.value;
192 [](std::pair<MoveOnlyInt, MoveOrCopyInt>
p) {
return p.first.value +
p.second.value; });
193 m.def(
"move_tuple", [](std::tuple<MoveOnlyInt, MoveOrCopyInt, MoveOnlyInt>
t) {
194 return std::get<0>(
t).value + std::get<1>(
t).value + std::get<2>(
t).value;
196 m.def(
"copy_tuple", [](std::tuple<CopyOnlyInt, CopyOnlyInt>
t) {
197 return std::get<0>(
t).value + std::get<1>(
t).value;
199 m.def(
"move_copy_nested",
203 return x.first.value + std::get<0>(
x.second.first).value
204 + std::get<1>(
x.second.first).value
205 + std::get<0>(std::get<2>(
x.second.first)).value +
x.second.second.value;
207 m.def(
"move_and_copy_cstats", []() {
210 auto &mc = ConstructorStats::get<MoveOrCopyInt>();
211 mc.move_assignments = mc.move_constructions = mc.copy_assignments = mc.copy_constructions
213 auto &mo = ConstructorStats::get<MoveOnlyInt>();
214 mo.move_assignments = mo.move_constructions = mo.copy_assignments = mo.copy_constructions
216 auto &co = ConstructorStats::get<CopyOnlyInt>();
217 co.move_assignments = co.move_constructions = co.copy_assignments = co.copy_constructions
220 d[
"MoveOrCopyInt"] =
py::cast(mc, py::return_value_policy::reference);
221 d[
"MoveOnlyInt"] =
py::cast(mo, py::return_value_policy::reference);
222 d[
"CopyOnlyInt"] =
py::cast(co, py::return_value_policy::reference);
225 #ifdef PYBIND11_HAS_OPTIONAL
227 m.attr(
"has_optional") =
true;
228 m.def(
"move_optional", [](std::optional<MoveOnlyInt> o) {
return o->value; });
229 m.def(
"move_or_copy_optional", [](std::optional<MoveOrCopyInt> o) {
return o->value; });
230 m.def(
"copy_optional", [](std::optional<CopyOnlyInt> o) {
return o->value; });
231 m.def(
"move_optional_tuple",
232 [](std::optional<std::tuple<MoveOrCopyInt, MoveOnlyInt, CopyOnlyInt>>
x) {
233 return std::get<0>(*x).value + std::get<1>(*x).value + std::get<2>(*x).value;
236 m.attr(
"has_optional") =
false;
243 struct PrivateOpNew {
247 void *
operator new(
size_t bytes) {
248 void *ptr = std::malloc(
bytes);
252 throw std::bad_alloc{};
256 m.def(
"private_op_new_value", []() {
return PrivateOpNew(); });
258 "private_op_new_reference",
259 []() ->
const PrivateOpNew & {
260 static PrivateOpNew
x{};
263 py::return_value_policy::reference);
269 explicit MoveIssue1(
int v) :
v{
v} {}
270 MoveIssue1(
const MoveIssue1 &
c) =
default;
271 MoveIssue1(MoveIssue1 &&) =
delete;
273 py::class_<MoveIssue1>(
m,
"MoveIssue1")
274 .def(py::init<int>())
279 explicit MoveIssue2(
int v) :
v{
v} {}
280 MoveIssue2(MoveIssue2 &&) =
default;
282 py::class_<MoveIssue2>(
m,
"MoveIssue2")
283 .def(py::init<int>())
290 [](
int i) {
return std::unique_ptr<MoveIssue1>(
new MoveIssue1(
i)); },
296 m.def(
"get_pytype_rvalue_castissue", [](
double i) {
return py::float_(
i).cast<py::int_>(); });
316 "!std::is_move_constructible<NotMovable>::value");
318 "std::is_copy_constructible<NotMovable>::value");
320 "!pybind11::detail::is_move_constructible<NotMovable>::value");
322 "pybind11::detail::is_copy_constructible<NotMovable>::value");
324 "!std::is_move_assignable<NotMovable>::value");
326 "std::is_copy_assignable<NotMovable>::value");
331 "pybind11::detail::is_copy_assignable<NotMovable>::value");
341 "std::is_move_constructible<NotCopyable>::value");
343 "!std::is_copy_constructible<NotCopyable>::value");
345 "pybind11::detail::is_move_constructible<NotCopyable>::value");
347 "!pybind11::detail::is_copy_constructible<NotCopyable>::value");
349 "std::is_move_assignable<NotCopyable>::value");
351 "!std::is_copy_assignable<NotCopyable>::value");
356 "!pybind11::detail::is_copy_assignable<NotCopyable>::value");
366 "!std::is_move_constructible<NotCopyableNotMovable>::value");
368 "!std::is_copy_constructible<NotCopyableNotMovable>::value");
370 "!pybind11::detail::is_move_constructible<NotCopyableNotMovable>::value");
372 "!pybind11::detail::is_copy_constructible<NotCopyableNotMovable>::value");
374 "!std::is_move_assignable<NotCopyableNotMovable>::value");
376 "!std::is_copy_assignable<NotCopyableNotMovable>::value");
381 "!pybind11::detail::is_copy_assignable<NotCopyableNotMovable>::value");
385 "std::is_move_constructible<NotMovableVector>::value");
387 "std::is_copy_constructible<NotMovableVector>::value");
389 "!pybind11::detail::is_move_constructible<NotMovableVector>::value");
391 "pybind11::detail::is_copy_constructible<NotMovableVector>::value");
393 "std::is_move_assignable<NotMovableVector>::value");
395 "std::is_copy_assignable<NotMovableVector>::value");
400 "pybind11::detail::is_copy_assignable<NotMovableVector>::value");
404 "std::is_move_constructible<NotCopyableVector>::value");
406 "std::is_copy_constructible<NotCopyableVector>::value");
408 "pybind11::detail::is_move_constructible<NotCopyableVector>::value");
410 "!pybind11::detail::is_copy_constructible<NotCopyableVector>::value");
412 "std::is_move_assignable<NotCopyableVector>::value");
414 "std::is_copy_assignable<NotCopyableVector>::value");
419 "!pybind11::detail::is_copy_assignable<NotCopyableVector>::value");
423 "std::is_move_constructible<NotCopyableNotMovableVector>::value");
425 "std::is_copy_constructible<NotCopyableNotMovableVector>::value");
427 "!pybind11::detail::is_move_constructible<NotCopyableNotMovableVector>::value");
429 "!pybind11::detail::is_copy_constructible<NotCopyableNotMovableVector>::value");
431 "std::is_move_assignable<NotCopyableNotMovableVector>::value");
433 "std::is_copy_assignable<NotCopyableNotMovableVector>::value");
438 "!pybind11::detail::is_copy_assignable<NotCopyableNotMovableVector>::value");
442 "std::is_move_constructible<NotMovableMap>::value");
444 "std::is_copy_constructible<NotMovableMap>::value");
446 "!pybind11::detail::is_move_constructible<NotMovableMap>::value");
448 "pybind11::detail::is_copy_constructible<NotMovableMap>::value");
450 "std::is_move_assignable<NotMovableMap>::value");
452 "std::is_copy_assignable<NotMovableMap>::value");
457 "pybind11::detail::is_copy_assignable<NotMovableMap>::value");
461 "std::is_move_constructible<NotCopyableMap>::value");
463 "std::is_copy_constructible<NotCopyableMap>::value");
465 "pybind11::detail::is_move_constructible<NotCopyableMap>::value");
467 "!pybind11::detail::is_copy_constructible<NotCopyableMap>::value");
469 "std::is_move_assignable<NotCopyableMap>::value");
471 "std::is_copy_assignable<NotCopyableMap>::value");
476 "!pybind11::detail::is_copy_assignable<NotCopyableMap>::value");
480 "std::is_move_constructible<NotCopyableNotMovableMap>::value");
482 "std::is_copy_constructible<NotCopyableNotMovableMap>::value");
484 "!pybind11::detail::is_move_constructible<NotCopyableNotMovableMap>::value");
486 "!pybind11::detail::is_copy_constructible<NotCopyableNotMovableMap>::value");
488 "std::is_move_assignable<NotCopyableNotMovableMap>::value");
490 "std::is_copy_assignable<NotCopyableNotMovableMap>::value");
495 "!pybind11::detail::is_copy_assignable<NotCopyableNotMovableMap>::value");
499 "std::is_move_constructible<RecursiveVector>::value");
501 "std::is_copy_constructible<RecursiveVector>::value");
503 "pybind11::detail::is_move_constructible<RecursiveVector>::value");
505 "pybind11::detail::is_copy_constructible<RecursiveVector>::value");
507 "std::is_move_assignable<RecursiveVector>::value");
509 "std::is_copy_assignable<RecursiveVector>::value");
514 "pybind11::detail::is_copy_assignable<RecursiveVector>::value");
518 "std::is_move_constructible<RecursiveMap>::value");
520 "std::is_copy_constructible<RecursiveMap>::value");
522 "pybind11::detail::is_move_constructible<RecursiveMap>::value");
524 "pybind11::detail::is_copy_constructible<RecursiveMap>::value");
526 "std::is_move_assignable<RecursiveMap>::value");
528 "std::is_copy_assignable<RecursiveMap>::value");
533 "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)
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 Mon Jul 1 2024 03:06:04