mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-25 14:45:12 +00:00
Add cast(const std::unique_ptr<type, deleter> &, ...)
. Remove the last 3 remaining BAKEIN_BREAK in test_class_sh_basic.cpp
This commit is contained in:
parent
ebbe066841
commit
874f69d898
@ -988,6 +988,20 @@ public:
|
||||
std::move(src), policy, parent);
|
||||
}
|
||||
|
||||
static handle
|
||||
cast(const std::unique_ptr<type, deleter> &src, return_value_policy policy, handle parent) {
|
||||
if (!src) {
|
||||
return none().release();
|
||||
}
|
||||
if (policy == return_value_policy::automatic) {
|
||||
policy = return_value_policy::reference_internal;
|
||||
}
|
||||
if (policy != return_value_policy::reference_internal) {
|
||||
throw cast_error("Invalid return_value_policy for unique_ptr&");
|
||||
}
|
||||
return type_caster_base<type>::cast(src.get(), policy, parent);
|
||||
}
|
||||
|
||||
bool load(handle src, bool convert) {
|
||||
return base::template load_impl<
|
||||
move_only_holder_caster<type, std::unique_ptr<type, deleter>>>(src, convert);
|
||||
|
@ -202,9 +202,8 @@ TEST_SUBMODULE(class_sh_basic, m) {
|
||||
.def("pass_valu", &uconsumer::pass_valu)
|
||||
.def("pass_rref", &uconsumer::pass_rref)
|
||||
.def("rtrn_valu", &uconsumer::rtrn_valu)
|
||||
// BAKEIN_BREAK .def("rtrn_lref", &uconsumer::rtrn_lref)
|
||||
// BAKEIN_BREAK .def("rtrn_cref", &uconsumer::rtrn_cref)
|
||||
;
|
||||
.def("rtrn_lref", &uconsumer::rtrn_lref)
|
||||
.def("rtrn_cref", &uconsumer::rtrn_cref);
|
||||
|
||||
// Helpers for testing.
|
||||
// These require selected functions above to work first, as indicated:
|
||||
@ -212,7 +211,7 @@ TEST_SUBMODULE(class_sh_basic, m) {
|
||||
m.def("get_ptr", get_ptr); // pass_cref
|
||||
|
||||
m.def("unique_ptr_roundtrip", unique_ptr_roundtrip); // pass_uqmp, rtrn_uqmp
|
||||
// BAKEIN_BREAK m.def("unique_ptr_cref_roundtrip", unique_ptr_cref_roundtrip);
|
||||
m.def("unique_ptr_cref_roundtrip", unique_ptr_cref_roundtrip);
|
||||
|
||||
py::classh<SharedPtrStash>(m, "SharedPtrStash")
|
||||
.def(py::init<>())
|
||||
|
Loading…
Reference in New Issue
Block a user