Skip to content

Commit 14bfe62

Browse files
jagermanwjakob
authored andcommitted
Simplify cast_op return type (#532)
Using a complicated declval here was pointlessly complicated: we already know the type, because that's what cast_op_type<T> is in the first place. (The declval also broke MSVC).
1 parent db86f7f commit 14bfe62

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

include/pybind11/cast.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -433,12 +433,10 @@ template <typename type, typename SFINAE = void> class type_caster : public type
433433
template <typename type> using make_caster = type_caster<intrinsic_t<type>>;
434434

435435
// Shortcut for calling a caster's `cast_op_type` cast operator for casting a type_caster to a T
436-
template <typename T>
437-
auto cast_op(make_caster<T> &caster) -> decltype(caster.operator typename make_caster<T>::template cast_op_type<T>()) {
436+
template <typename T> typename make_caster<T>::template cast_op_type<T> cast_op(make_caster<T> &caster) {
438437
return caster.operator typename make_caster<T>::template cast_op_type<T>();
439438
}
440-
template <typename T>
441-
auto cast_op(make_caster<T> &&caster) -> decltype(caster.operator typename make_caster<T>::template cast_op_type<T>()) {
439+
template <typename T> typename make_caster<T>::template cast_op_type<T> cast_op(make_caster<T> &&caster) {
442440
return cast_op<T>(caster);
443441
}
444442

0 commit comments

Comments
 (0)