mirror of
https://github.com/pybind/pybind11.git
synced 2026-03-14 20:27:47 +00:00
Trivial refactoring to make the capsule API more user friendly. (#4720)
* Trivial refactoring to make the capsule API more user friendly. * Use new API in production code. Thanks @Lalaland for pointing this out.
This commit is contained in:
committed by
GitHub
parent
e10da79b6e
commit
2fb3d7cbde
@@ -260,6 +260,15 @@ TEST_SUBMODULE(pytypes, m) {
|
||||
});
|
||||
});
|
||||
|
||||
m.def("return_capsule_with_destructor_3", []() {
|
||||
py::print("creating capsule");
|
||||
auto cap = py::capsule((void *) 1233, "oname", [](void *ptr) {
|
||||
py::print("destructing capsule: {}"_s.format((size_t) ptr));
|
||||
});
|
||||
py::print("original name: {}"_s.format(cap.name()));
|
||||
return cap;
|
||||
});
|
||||
|
||||
m.def("return_renamed_capsule_with_destructor_2", []() {
|
||||
py::print("creating capsule");
|
||||
auto cap = py::capsule((void *) 1234, [](void *ptr) {
|
||||
|
||||
Reference in New Issue
Block a user