| 1675 | && !detail::is_same_ignoring_cvref<T, PyObject *>::value, |
| 1676 | int> = 0> |
| 1677 | T cast(const handle &handle) { |
| 1678 | using namespace detail; |
| 1679 | constexpr bool is_enum_cast = type_uses_type_caster_enum_type<intrinsic_t<T>>::value; |
| 1680 | static_assert(!cast_is_temporary_value_reference<T>::value || is_enum_cast, |
| 1681 | "Unable to cast type to reference: value is local to type caster"); |
| 1682 | #ifndef NDEBUG |
| 1683 | if (is_enum_cast && cast_is_temporary_value_reference<T>::value) { |
| 1684 | if (detail::global_internals_native_enum_type_map_contains( |
| 1685 | std::type_index(typeid(intrinsic_t<T>)))) { |
| 1686 | pybind11_fail("Unable to cast native enum type to reference"); |
| 1687 | } |
| 1688 | } |
| 1689 | #endif |
| 1690 | return cast_op<T>(load_type<T>(handle)); |
| 1691 | } |
| 1692 | |
| 1693 | // pytype -> pytype (calls converting constructor) |
| 1694 | template <typename T, detail::enable_if_t<detail::is_pyobject<T>::value, int> = 0> |
no test coverage detected