Undoing all debug changes, keeping just the change to using std::is_base_of.

parent 3e3f99f9
...@@ -1218,9 +1218,6 @@ struct smart_holder_type_caster_class_hooks { ...@@ -1218,9 +1218,6 @@ struct smart_holder_type_caster_class_hooks {
} }
}; };
template <typename T, typename SFINAE = void>
struct is_smart_holder_type_caster { static constexpr bool value = false; };
template <typename T> template <typename T>
inline bool check_is_smart_holder_type_caster(); inline bool check_is_smart_holder_type_caster();
...@@ -1388,7 +1385,6 @@ struct smart_holder_type_caster : smart_holder_type_caster_load<T>, ...@@ -1388,7 +1385,6 @@ struct smart_holder_type_caster : smart_holder_type_caster_load<T>,
// clang-format off // clang-format off
#if 0
template <typename T_> template <typename T_>
using cast_op_type = conditional_t< using cast_op_type = conditional_t<
std::is_same<remove_reference_t<T_>, T const *>::value, std::is_same<remove_reference_t<T_>, T const *>::value,
...@@ -1398,13 +1394,10 @@ struct smart_holder_type_caster : smart_holder_type_caster_load<T>, ...@@ -1398,13 +1394,10 @@ struct smart_holder_type_caster : smart_holder_type_caster_load<T>,
conditional_t<std::is_same<T_, T const &>::value, conditional_t<std::is_same<T_, T const &>::value,
T const &, T const &,
T &>>>; T &>>>;
#else
template <typename T_> using cast_op_type = detail::cast_op_type<T_>;
#endif
// rator T const&() { return this->loaded_as_lvalue_ref(); } operator T const&() { return this->loaded_as_lvalue_ref(); }
operator T&() { return this->loaded_as_lvalue_ref(); } operator T&() { return this->loaded_as_lvalue_ref(); }
// rator T const*() { return this->loaded_as_raw_ptr_unowned(); } operator T const*() { return this->loaded_as_raw_ptr_unowned(); }
operator T*() { return this->loaded_as_raw_ptr_unowned(); } operator T*() { return this->loaded_as_raw_ptr_unowned(); }
// clang-format on // clang-format on
...@@ -1692,19 +1685,6 @@ template <typename type, typename SFINAE = void> class type_caster : public type ...@@ -1692,19 +1685,6 @@ template <typename type, typename SFINAE = void> class type_caster : public type
template <typename type> using make_caster = type_caster<intrinsic_t<type>>; template <typename type> using make_caster = type_caster<intrinsic_t<type>>;
template <typename T>
struct is_smart_holder_type_caster<
T,
typename std::enable_if<
std::is_base_of<smart_holder_type_caster_class_hooks, make_caster<T>>::value>::type> {
static constexpr bool value = true;
};
template <typename T>
inline bool check_is_smart_holder_type_caster() {
return detail::is_smart_holder_type_caster<T>::value;
}
// Shortcut for calling a caster's `cast_op_type` cast operator for casting a type_caster to a T // Shortcut for calling a caster's `cast_op_type` cast operator for casting a type_caster to a T
template <typename T> typename make_caster<T>::template cast_op_type<T> cast_op(make_caster<T> &caster) { template <typename T> typename make_caster<T>::template cast_op_type<T> cast_op(make_caster<T> &caster) {
return caster.operator typename make_caster<T>::template cast_op_type<T>(); return caster.operator typename make_caster<T>::template cast_op_type<T>();
...@@ -2472,6 +2452,21 @@ template <typename T> struct move_if_unreferenced<T, enable_if_t<all_of< ...@@ -2472,6 +2452,21 @@ 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,
typename std::enable_if<
std::is_base_of<smart_holder_type_caster_class_hooks, make_caster<T>>::value>::type>
: std::true_type {};
template <typename T>
inline bool check_is_smart_holder_type_caster() {
return is_smart_holder_type_caster<T>::value;
}
// 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;
...@@ -2526,7 +2521,7 @@ T cast(const handle &handle) { ...@@ -2526,7 +2521,7 @@ T cast(const handle &handle) {
using namespace detail; using namespace detail;
static_assert(!cast_is_temporary_value_reference<T>::value, static_assert(!cast_is_temporary_value_reference<T>::value,
"Unable to cast type to reference: value is local to type caster"); "Unable to cast type to reference: value is local to type caster");
return cast_op<T>(load_type<T>(handle)); // HEERE 2 return cast_op<T>(load_type<T>(handle));
} }
// pytype -> pytype (calls converting constructor) // pytype -> pytype (calls converting constructor)
...@@ -2581,7 +2576,7 @@ template <typename T> detail::enable_if_t<detail::move_if_unreferenced<T>::value ...@@ -2581,7 +2576,7 @@ template <typename T> detail::enable_if_t<detail::move_if_unreferenced<T>::value
return move<T>(std::move(object)); return move<T>(std::move(object));
} }
template <typename T> detail::enable_if_t<detail::move_never<T>::value, T> cast(object &&object) { template <typename T> detail::enable_if_t<detail::move_never<T>::value, T> cast(object &&object) {
return cast<T>(object); // HERE 2 return cast<T>(object);
} }
template <typename T> T object::cast() const & { return pybind11::cast<T>(*this); } template <typename T> T object::cast() const & { return pybind11::cast<T>(*this); }
...@@ -2611,7 +2606,7 @@ template <typename T> enable_if_t<!cast_is_temporary_value_reference<T>::value, ...@@ -2611,7 +2606,7 @@ template <typename T> enable_if_t<!cast_is_temporary_value_reference<T>::value,
// though if it's in dead code, so we provide a "trampoline" to pybind11::cast that only does anything in // though if it's in dead code, so we provide a "trampoline" to pybind11::cast that only does anything in
// cases where pybind11::cast is valid. // cases where pybind11::cast is valid.
template <typename T> enable_if_t<!cast_is_temporary_value_reference<T>::value, T> cast_safe(object &&o) { template <typename T> enable_if_t<!cast_is_temporary_value_reference<T>::value, T> cast_safe(object &&o) {
return pybind11::cast<T>(std::move(o)); } // HEERE 1 return pybind11::cast<T>(std::move(o)); }
template <typename T> enable_if_t<cast_is_temporary_value_reference<T>::value, T> cast_safe(object &&) { template <typename T> enable_if_t<cast_is_temporary_value_reference<T>::value, T> cast_safe(object &&) {
pybind11_fail("Internal error: cast_safe fallback invoked"); } pybind11_fail("Internal error: cast_safe fallback invoked"); }
template <> inline void cast_safe<void>(object &&) {} template <> inline void cast_safe<void>(object &&) {}
......
...@@ -1286,7 +1286,6 @@ public: ...@@ -1286,7 +1286,6 @@ public:
none_of<std::is_same<multiple_inheritance, Extra>...>::value), // no multiple_inheritance attr none_of<std::is_same<multiple_inheritance, Extra>...>::value), // no multiple_inheritance attr
"Error: multiple inheritance bases must be specified via class_ template options"); "Error: multiple inheritance bases must be specified via class_ template options");
# if 1
static constexpr bool holder_is_smart_holder = std::is_same<holder_type, smart_holder>::value; static constexpr bool holder_is_smart_holder = std::is_same<holder_type, smart_holder>::value;
static constexpr bool type_caster_type_is_smart_holder_type_caster = detail::is_smart_holder_type_caster<type>::value; static constexpr bool type_caster_type_is_smart_holder_type_caster = detail::is_smart_holder_type_caster<type>::value;
static constexpr bool type_caster_type_is_type_caster_base_subtype = std::is_base_of<detail::type_caster_base<type>, detail::type_caster<type>>::value; static constexpr bool type_caster_type_is_type_caster_base_subtype = std::is_base_of<detail::type_caster_base<type>, detail::type_caster<type>>::value;
...@@ -1313,7 +1312,6 @@ public: ...@@ -1313,7 +1312,6 @@ public:
" missing PYBIND11_SMART_POINTER_HOLDER_TYPE_CASTERS(T, ...)" " missing PYBIND11_SMART_POINTER_HOLDER_TYPE_CASTERS(T, ...)"
" or collision with custom py::detail::type_caster<T>?"); " or collision with custom py::detail::type_caster<T>?");
#endif #endif
#endif
type_record record; type_record record;
record.scope = scope; record.scope = scope;
record.name = name; record.name = name;
......
...@@ -78,7 +78,7 @@ public: ...@@ -78,7 +78,7 @@ public:
// We can return reference types for compatibility with C++ virtual interfaces that do so, but // We can return reference types for compatibility with C++ virtual interfaces that do so, but
// note they have some significant limitations (see the documentation). // note they have some significant limitations (see the documentation).
const std::string &get_string1() override { const std::string &get_string1() override {
PYBIND11_OVERRIDE( // HEERE 0 PYBIND11_OVERRIDE(
const std::string &, /* Return type */ const std::string &, /* Return type */
ExampleVirt, /* Parent class */ ExampleVirt, /* Parent class */
get_string1, /* Name of function */ get_string1, /* Name of function */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment