diff --git a/include/pybind11/detail/smart_holder_type_casters.h b/include/pybind11/detail/smart_holder_type_casters.h index f048aaf29..5e6b0c016 100644 --- a/include/pybind11/detail/smart_holder_type_casters.h +++ b/include/pybind11/detail/smart_holder_type_casters.h @@ -716,7 +716,8 @@ struct smart_holder_type_caster> : smart_holder_type_caste return inst.release(); } - static handle cast(const std::unique_ptr &src, return_value_policy policy, handle parent) { + static handle + cast(const std::unique_ptr &src, return_value_policy policy, handle parent) { if (!src) return none().release(); if (policy == return_value_policy::automatic) diff --git a/tests/test_class_sh_basic.cpp b/tests/test_class_sh_basic.cpp index 9bfbe081a..ff9f97607 100644 --- a/tests/test_class_sh_basic.cpp +++ b/tests/test_class_sh_basic.cpp @@ -17,14 +17,14 @@ struct atyp { // Short for "any type". atyp(atyp &&other) { mtxt = other.mtxt + "_MvCtor"; } }; -struct uconsumer { // unique_ptr consumer +struct uconsumer { // unique_ptr consumer std::unique_ptr held; bool valid() const { return static_cast(held); } void pass_valu(std::unique_ptr obj) { held = std::move(obj); } void pass_rref(std::unique_ptr &&obj) { held = std::move(obj); } std::unique_ptr rtrn_valu() { return std::move(held); } - std::unique_ptr& rtrn_lref() { return held; } + std::unique_ptr &rtrn_lref() { return held; } const std::unique_ptr &rtrn_cref() { return held; } }; @@ -71,7 +71,9 @@ std::string get_mtxt(atyp const &obj) { return obj.mtxt; } std::ptrdiff_t get_ptr(atyp const &obj) { return reinterpret_cast(&obj); } std::unique_ptr unique_ptr_roundtrip(std::unique_ptr obj) { return obj; } -const std::unique_ptr& unique_ptr_cref_roundtrip(const std::unique_ptr& obj) { return obj; } +const std::unique_ptr &unique_ptr_cref_roundtrip(const std::unique_ptr &obj) { + return obj; +} struct SharedPtrStash { std::vector> stash; @@ -139,8 +141,8 @@ TEST_SUBMODULE(class_sh_basic, m) { // Helpers for testing. // These require selected functions above to work first, as indicated: - m.def("get_mtxt", get_mtxt); // pass_cref - m.def("get_ptr", get_ptr); // pass_cref + m.def("get_mtxt", get_mtxt); // pass_cref + m.def("get_ptr", get_ptr); // pass_cref m.def("unique_ptr_roundtrip", unique_ptr_roundtrip); // pass_uqmp, rtrn_uqmp m.def("unique_ptr_cref_roundtrip", unique_ptr_cref_roundtrip);