From 35b1177f421c32ec48ca811a43b649d103510438 Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Fri, 19 Jul 2024 19:06:07 -0700 Subject: [PATCH] Small cleanup in detail/init.h: strip `originally_smart_holder_type_casters_h` namespace. --- include/pybind11/detail/init.h | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/include/pybind11/detail/init.h b/include/pybind11/detail/init.h index a2cfd8e61..af8ec6dd4 100644 --- a/include/pybind11/detail/init.h +++ b/include/pybind11/detail/init.h @@ -200,20 +200,13 @@ void construct(value_and_holder &v_h, Alias &&result, bool) { #ifdef PYBIND11_HAVE_INTERNALS_WITH_SMART_HOLDER_SUPPORT -namespace originally_smart_holder_type_casters_h { template -smart_holder smart_holder_from_unique_ptr(std::unique_ptr &&unq_ptr, - bool void_cast_raw_ptr) { +smart_holder init_smart_holder_from_unique_ptr(std::unique_ptr &&unq_ptr, + bool void_cast_raw_ptr) { void *void_ptr = void_cast_raw_ptr ? static_cast(unq_ptr.get()) : nullptr; return smart_holder::from_unique_ptr(std::move(unq_ptr), void_ptr); } -template -smart_holder smart_holder_from_shared_ptr(std::shared_ptr shd_ptr) { - return smart_holder::from_shared_ptr(shd_ptr); -} -} // namespace originally_smart_holder_type_casters_h - template >, detail::enable_if_t>::value, int> = 0> @@ -230,7 +223,7 @@ void construct(value_and_holder &v_h, std::unique_ptr, D> &&unq_ptr, // trampoline Python object alive. For types that don't inherit from enable_shared_from_this // it does not matter if void_cast_raw_ptr is true or false, therefore it's not necessary // to also inspect the type. - auto smhldr = originally_smart_holder_type_casters_h::smart_holder_from_unique_ptr( + auto smhldr = init_smart_holder_from_unique_ptr( std::move(unq_ptr), /*void_cast_raw_ptr*/ Class::has_alias && is_alias(ptr)); v_h.value_ptr() = ptr; v_h.type->init_instance(v_h.inst, &smhldr); @@ -244,8 +237,8 @@ void construct(value_and_holder &v_h, bool /*need_alias*/) { auto *ptr = unq_ptr.get(); no_nullptr(ptr); - auto smhldr = originally_smart_holder_type_casters_h::smart_holder_from_unique_ptr( - std::move(unq_ptr), /*void_cast_raw_ptr*/ true); + auto smhldr + = init_smart_holder_from_unique_ptr(std::move(unq_ptr), /*void_cast_raw_ptr*/ true); v_h.value_ptr() = ptr; v_h.type->init_instance(v_h.inst, &smhldr); } @@ -259,7 +252,7 @@ void construct(value_and_holder &v_h, std::shared_ptr> &&shd_ptr, boo throw type_error("pybind11::init(): construction failed: returned std::shared_ptr pointee " "is not an alias instance"); } - auto smhldr = originally_smart_holder_type_casters_h::smart_holder_from_shared_ptr(shd_ptr); + auto smhldr = smart_holder::from_shared_ptr(shd_ptr); v_h.value_ptr() = ptr; v_h.type->init_instance(v_h.inst, &smhldr); } @@ -270,7 +263,7 @@ void construct(value_and_holder &v_h, bool /*need_alias*/) { auto *ptr = shd_ptr.get(); no_nullptr(ptr); - auto smhldr = originally_smart_holder_type_casters_h::smart_holder_from_shared_ptr(shd_ptr); + auto smhldr = smart_holder::from_shared_ptr(shd_ptr); v_h.value_ptr() = ptr; v_h.type->init_instance(v_h.inst, &smhldr); }