@@ -42,7 +42,13 @@ struct type_caster<absl::StatusOr<PayloadType>> {
42
42
using PayloadCaster = make_caster<PayloadType>;
43
43
using StatusCaster = make_caster<absl::Status>;
44
44
45
+ #if defined(PYBIND11_HAS_RETURN_VALUE_POLICY_PACK)
46
+ using return_value_policy_t = const return_value_policy_pack&;
47
+ PYBIND11_TYPE_CASTER_RVPP (absl::StatusOr<PayloadType>, PayloadCaster::name);
48
+ #else
49
+ using return_value_policy_t = return_value_policy;
45
50
PYBIND11_TYPE_CASTER (absl::StatusOr<PayloadType>, PayloadCaster::name);
51
+ #endif
46
52
47
53
bool load (handle src, bool convert) {
48
54
PayloadCaster payload_caster;
@@ -70,27 +76,27 @@ struct type_caster<absl::StatusOr<PayloadType>> {
70
76
71
77
// Convert C++ -> Python.
72
78
static handle cast (const absl::StatusOr<PayloadType>* src,
73
- return_value_policy policy, handle parent,
79
+ return_value_policy_t policy, handle parent,
74
80
bool throw_exception = true ) {
75
81
if (!src) return none ().release ();
76
82
return cast_impl (*src, policy, parent, throw_exception);
77
83
}
78
84
79
85
static handle cast (const absl::StatusOr<PayloadType>& src,
80
- return_value_policy policy, handle parent,
86
+ return_value_policy_t policy, handle parent,
81
87
bool throw_exception = true ) {
82
88
return cast_impl (src, policy, parent, throw_exception);
83
89
}
84
90
85
91
static handle cast (absl::StatusOr<PayloadType>&& src,
86
- return_value_policy policy, handle parent,
92
+ return_value_policy_t policy, handle parent,
87
93
bool throw_exception = true ) {
88
94
return cast_impl (std::move (src), policy, parent, throw_exception);
89
95
}
90
96
91
97
private:
92
98
template <typename CType>
93
- static handle cast_impl (CType&& src, return_value_policy policy,
99
+ static handle cast_impl (CType&& src, return_value_policy_t policy,
94
100
handle parent, bool throw_exception) {
95
101
google::internal::CheckStatusModuleImported ();
96
102
if (src.ok ()) {
0 commit comments