mirror of
https://github.com/pybind/pybind11.git
synced 2026-04-20 14:59:27 +00:00
Adding pybind11::cast overload for rvalue references (#1260)
* Adding pybind11::cast overload for rvalue references
This commit is contained in:
@@ -291,7 +291,8 @@ TEST_SUBMODULE(smart_ptr, m) {
|
||||
~C() { print_destroyed(this); }
|
||||
};
|
||||
py::class_<C, custom_unique_ptr<C>>(m, "TypeWithMoveOnlyHolder")
|
||||
.def_static("make", []() { return custom_unique_ptr<C>(new C); });
|
||||
.def_static("make", []() { return custom_unique_ptr<C>(new C); })
|
||||
.def_static("make_as_object", []() { return py::cast(custom_unique_ptr<C>(new C)); });
|
||||
|
||||
// test_holder_with_addressof_operator
|
||||
struct TypeForHolderWithAddressOf {
|
||||
|
||||
@@ -218,7 +218,10 @@ def test_shared_ptr_from_this_and_references():
|
||||
|
||||
def test_move_only_holder():
|
||||
a = m.TypeWithMoveOnlyHolder.make()
|
||||
b = m.TypeWithMoveOnlyHolder.make_as_object()
|
||||
stats = ConstructorStats.get(m.TypeWithMoveOnlyHolder)
|
||||
assert stats.alive() == 2
|
||||
del b
|
||||
assert stats.alive() == 1
|
||||
del a
|
||||
assert stats.alive() == 0
|
||||
|
||||
Reference in New Issue
Block a user