diff --git a/include/pybind11/cast.h b/include/pybind11/cast.h index 95a9a4a7e3..b99620393c 100644 --- a/include/pybind11/cast.h +++ b/include/pybind11/cast.h @@ -902,6 +902,8 @@ template struct copyable_holder_caster : public type_caster_base { public: using base = type_caster_base; + static_assert(std::is_base_of>::value, + "Holder classes are only supported for custom types"); using base::base; using base::cast; using base::typeinfo; @@ -1018,6 +1020,9 @@ class type_caster> : public copyable_holder_caster struct move_only_holder_caster { + static_assert(std::is_base_of, type_caster>::value, + "Holder classes are only supported for custom types"); + static handle cast(holder_type &&src, return_value_policy, handle) { auto *ptr = holder_helper::get(src); return type_caster_base::cast_holder(ptr, &src);