Moving up is_smart_holder_type_caster, to also use in cast_is_temporary_value_reference.

This commit is contained in:
Ralf W. Grosse-Kunstleve 2021-01-30 00:42:36 -08:00
parent 692270a017
commit 231bd84fa0
1 changed files with 9 additions and 8 deletions

View File

@ -1717,6 +1717,13 @@ template <typename T> struct move_if_unreferenced<T, enable_if_t<all_of<
>::value>> : std::true_type {}; >::value>> : std::true_type {};
template <typename T> using move_never = none_of<move_always<T>, move_if_unreferenced<T>>; template <typename T> using move_never = none_of<move_always<T>, move_if_unreferenced<T>>;
template <typename T, typename SFINAE = void>
struct is_smart_holder_type_caster : std::false_type {};
template <typename T>
struct is_smart_holder_type_caster<
T,
enable_if_t<type_caster<T>::is_smart_holder_type_caster::value, void>> : std::true_type {};
// Detect whether returning a `type` from a cast on type's type_caster is going to result in a // Detect whether returning a `type` from a cast on type's type_caster is going to result in a
// reference or pointer to a local variable of the type_caster. Basically, only // reference or pointer to a local variable of the type_caster. Basically, only
// non-reference/pointer `type`s and reference/pointers from a type_caster_generic are safe; // non-reference/pointer `type`s and reference/pointers from a type_caster_generic are safe;
@ -1724,7 +1731,8 @@ template <typename T> using move_never = none_of<move_always<T>, move_if_unrefer
template <typename type> using cast_is_temporary_value_reference = bool_constant< template <typename type> using cast_is_temporary_value_reference = bool_constant<
(std::is_reference<type>::value || std::is_pointer<type>::value) && (std::is_reference<type>::value || std::is_pointer<type>::value) &&
!std::is_base_of<type_caster_generic, make_caster<type>>::value && !std::is_base_of<type_caster_generic, make_caster<type>>::value &&
!std::is_same<intrinsic_t<type>, void>::value !std::is_same<intrinsic_t<type>, void>::value &&
!is_smart_holder_type_caster<intrinsic_t<type>>::value
>; >;
// When a value returned from a C++ function is being cast back to Python, we almost always want to // When a value returned from a C++ function is being cast back to Python, we almost always want to
@ -2261,13 +2269,6 @@ object object_api<Derived>::call(Args &&...args) const {
return operator()<policy>(std::forward<Args>(args)...); return operator()<policy>(std::forward<Args>(args)...);
} }
template <typename T, typename SFINAE = void>
struct is_smart_holder_type_caster : std::false_type {};
template <typename T>
struct is_smart_holder_type_caster<
T,
enable_if_t<type_caster<T>::is_smart_holder_type_caster::value, void>> : std::true_type {};
PYBIND11_NAMESPACE_END(detail) PYBIND11_NAMESPACE_END(detail)