@@ -42,7 +42,13 @@ struct type_caster<absl::StatusOr<PayloadType>> {
4242 using PayloadCaster = make_caster<PayloadType>;
4343 using StatusCaster = make_caster<absl::Status>;
4444
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;
4550 PYBIND11_TYPE_CASTER (absl::StatusOr<PayloadType>, PayloadCaster::name);
51+ #endif
4652
4753 bool load (handle src, bool convert) {
4854 PayloadCaster payload_caster;
@@ -70,27 +76,27 @@ struct type_caster<absl::StatusOr<PayloadType>> {
7076
7177 // Convert C++ -> Python.
7278 static handle cast (const absl::StatusOr<PayloadType>* src,
73- return_value_policy policy, handle parent,
79+ return_value_policy_t policy, handle parent,
7480 bool throw_exception = true ) {
7581 if (!src) return none ().release ();
7682 return cast_impl (*src, policy, parent, throw_exception);
7783 }
7884
7985 static handle cast (const absl::StatusOr<PayloadType>& src,
80- return_value_policy policy, handle parent,
86+ return_value_policy_t policy, handle parent,
8187 bool throw_exception = true ) {
8288 return cast_impl (src, policy, parent, throw_exception);
8389 }
8490
8591 static handle cast (absl::StatusOr<PayloadType>&& src,
86- return_value_policy policy, handle parent,
92+ return_value_policy_t policy, handle parent,
8793 bool throw_exception = true ) {
8894 return cast_impl (std::move (src), policy, parent, throw_exception);
8995 }
9096
9197 private:
9298 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,
94100 handle parent, bool throw_exception) {
95101 google::internal::CheckStatusModuleImported ();
96102 if (src.ok ()) {
0 commit comments