pybind11/detail/init.h: replace type_uses_smart_holder_type_caster<> with is_same<Holder<Class>, smart_holder> (still does not build).

This commit is contained in:
Ralf W. Grosse-Kunstleve 2024-06-30 11:22:41 -07:00
parent 03e6a93c73
commit e8cd42953e

View File

@ -10,7 +10,7 @@
#pragma once
#include "class.h"
#include "smart_holder_sfinae_hooks_only.h"
#include "smart_holder_poc.h"
PYBIND11_NAMESPACE_BEGIN(PYBIND11_NAMESPACE)
@ -156,9 +156,10 @@ void construct(value_and_holder &v_h, Alias<Class> *alias_ptr, bool) {
// holder. This also handles types like std::shared_ptr<T> and std::unique_ptr<T> where T is a
// derived type (through those holder's implicit conversion from derived class holder
// constructors).
template <typename Class,
detail::enable_if_t<!detail::type_uses_smart_holder_type_caster<Cpp<Class>>::value, int>
= 0>
template <
typename Class,
detail::enable_if_t<!std::is_same<Holder<Class>, pybindit::memory::smart_holder>::value, int>
= 0>
void construct(value_and_holder &v_h, Holder<Class> holder, bool need_alias) {
PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(need_alias);
auto *ptr = holder_helper<Holder<Class>>::get(holder);
@ -200,10 +201,11 @@ void construct(value_and_holder &v_h, Alias<Class> &&result, bool) {
v_h.value_ptr() = new Alias<Class>(std::move(result));
}
template <typename Class,
typename D = std::default_delete<Cpp<Class>>,
detail::enable_if_t<detail::type_uses_smart_holder_type_caster<Cpp<Class>>::value, int>
= 0>
template <
typename Class,
typename D = std::default_delete<Cpp<Class>>,
detail::enable_if_t<std::is_same<Holder<Class>, pybindit::memory::smart_holder>::value, int>
= 0>
void construct(value_and_holder &v_h, std::unique_ptr<Cpp<Class>, D> &&unq_ptr, bool need_alias) {
PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(need_alias);
auto *ptr = unq_ptr.get();
@ -223,10 +225,11 @@ void construct(value_and_holder &v_h, std::unique_ptr<Cpp<Class>, D> &&unq_ptr,
v_h.type->init_instance(v_h.inst, &smhldr);
}
template <typename Class,
typename D = std::default_delete<Alias<Class>>,
detail::enable_if_t<detail::type_uses_smart_holder_type_caster<Alias<Class>>::value, int>
= 0>
template <
typename Class,
typename D = std::default_delete<Alias<Class>>,
detail::enable_if_t<std::is_same<Holder<Class>, pybindit::memory::smart_holder>::value, int>
= 0>
void construct(value_and_holder &v_h,
std::unique_ptr<Alias<Class>, D> &&unq_ptr,
bool /*need_alias*/) {
@ -238,9 +241,10 @@ void construct(value_and_holder &v_h,
v_h.type->init_instance(v_h.inst, &smhldr);
}
template <typename Class,
detail::enable_if_t<detail::type_uses_smart_holder_type_caster<Cpp<Class>>::value, int>
= 0>
template <
typename Class,
detail::enable_if_t<std::is_same<Holder<Class>, pybindit::memory::smart_holder>::value, int>
= 0>
void construct(value_and_holder &v_h, std::shared_ptr<Cpp<Class>> &&shd_ptr, bool need_alias) {
PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(need_alias);
auto *ptr = shd_ptr.get();
@ -254,9 +258,10 @@ void construct(value_and_holder &v_h, std::shared_ptr<Cpp<Class>> &&shd_ptr, boo
v_h.type->init_instance(v_h.inst, &smhldr);
}
template <typename Class,
detail::enable_if_t<detail::type_uses_smart_holder_type_caster<Alias<Class>>::value, int>
= 0>
template <
typename Class,
detail::enable_if_t<std::is_same<Holder<Class>, pybindit::memory::smart_holder>::value, int>
= 0>
void construct(value_and_holder &v_h,
std::shared_ptr<Alias<Class>> &&shd_ptr,
bool /*need_alias*/) {