mirror of
https://github.com/pybind/pybind11.git
synced 2024-12-01 17:37:15 +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:
|
private:
|
||||||
template <typename T = type,
|
template <
|
||||||
detail::enable_if_t<
|
typename T = type,
|
||||||
std::is_base_of<detail::type_caster_generic, detail::type_caster<T>>::value,
|
detail::enable_if_t<!detail::is_smart_holder_type_caster<T>::value, int> = 0>
|
||||||
int> = 0>
|
|
||||||
void generic_type_initialize(const detail::type_record &record) {
|
void generic_type_initialize(const detail::type_record &record) {
|
||||||
generic_type::initialize(record, &detail::type_caster_generic::local_load);
|
generic_type::initialize(record, &detail::type_caster_generic::local_load);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <
|
template <
|
||||||
typename T = type,
|
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) {
|
void generic_type_initialize(const detail::type_record &record) {
|
||||||
generic_type::initialize(record, detail::type_caster<T>::get_local_load_function_ptr());
|
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
|
/// 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
|
/// 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.
|
/// `.owned`, a new holder will be constructed to manage the value pointer.
|
||||||
template <typename T = type,
|
template <
|
||||||
detail::enable_if_t<
|
typename T = type,
|
||||||
std::is_base_of<detail::type_caster_generic, detail::type_caster<T>>::value,
|
detail::enable_if_t<!detail::is_smart_holder_type_caster<T>::value, int> = 0>
|
||||||
int> = 0>
|
|
||||||
static void init_instance(detail::instance *inst, const void *holder_ptr) {
|
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)));
|
auto v_h = inst->get_value_and_holder(detail::get_type_info(typeid(type)));
|
||||||
if (!v_h.instance_registered()) {
|
if (!v_h.instance_registered()) {
|
||||||
@ -1580,7 +1578,7 @@ private:
|
|||||||
|
|
||||||
template <
|
template <
|
||||||
typename T = type,
|
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) {
|
static void init_instance(detail::instance *inst, const void *holder_ptr) {
|
||||||
detail::type_caster<T>::template init_instance_for_type<type>(inst, holder_ptr);
|
detail::type_caster<T>::template init_instance_for_type<type>(inst, holder_ptr);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user