mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-29 08:32:02 +00:00
Giving up on idea to use legacy init_instance only if is_base_of<type_caster_generic, type_caster<T>. There are use cases in the wild that define both a custom type_caster and class_.
This commit is contained in:
parent
149e332b3e
commit
c9d73aaa43
@ -1506,17 +1506,16 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
template <typename T = type,
|
||||
detail::enable_if_t<
|
||||
std::is_base_of<detail::type_caster_generic, detail::type_caster<T>>::value,
|
||||
int> = 0>
|
||||
template <
|
||||
typename T = type,
|
||||
detail::enable_if_t<!detail::is_smart_holder_type_caster<T>::value, int> = 0>
|
||||
void generic_type_initialize(const detail::type_record &record) {
|
||||
generic_type::initialize(record, &detail::type_caster_generic::local_load);
|
||||
}
|
||||
|
||||
template <
|
||||
typename T = type,
|
||||
detail::enable_if_t<detail::type_caster<T>::is_smart_holder_type_caster::value, int> = 0>
|
||||
detail::enable_if_t<detail::is_smart_holder_type_caster<T>::value, int> = 0>
|
||||
void generic_type_initialize(const detail::type_record &record) {
|
||||
generic_type::initialize(record, detail::type_caster<T>::get_local_load_function_ptr());
|
||||
}
|
||||
@ -1565,10 +1564,9 @@ private:
|
||||
/// instance. Should be called as soon as the `type` value_ptr is set for an instance. Takes an
|
||||
/// optional pointer to an existing holder to use; if not specified and the instance is
|
||||
/// `.owned`, a new holder will be constructed to manage the value pointer.
|
||||
template <typename T = type,
|
||||
detail::enable_if_t<
|
||||
std::is_base_of<detail::type_caster_generic, detail::type_caster<T>>::value,
|
||||
int> = 0>
|
||||
template <
|
||||
typename T = type,
|
||||
detail::enable_if_t<!detail::is_smart_holder_type_caster<T>::value, int> = 0>
|
||||
static void init_instance(detail::instance *inst, const void *holder_ptr) {
|
||||
auto v_h = inst->get_value_and_holder(detail::get_type_info(typeid(type)));
|
||||
if (!v_h.instance_registered()) {
|
||||
@ -1580,7 +1578,7 @@ private:
|
||||
|
||||
template <
|
||||
typename T = type,
|
||||
detail::enable_if_t<detail::type_caster<T>::is_smart_holder_type_caster::value, int> = 0>
|
||||
detail::enable_if_t<detail::is_smart_holder_type_caster<T>::value, int> = 0>
|
||||
static void init_instance(detail::instance *inst, const void *holder_ptr) {
|
||||
detail::type_caster<T>::template init_instance_for_type<type>(inst, holder_ptr);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user