@@ -85,14 +85,14 @@ struct set_caster {
8585 }
8686
8787 template <typename T>
88- static handle cast (T &&src, return_value_policy policy , handle parent) {
88+ static handle cast (T &&src, return_value_policy_pack rvpp , handle parent) {
8989 if (!std::is_lvalue_reference<T>::value) {
90- policy = return_value_policy_override<Key>::policy ( policy);
90+ rvpp = rvpp. override_policy ( return_value_policy_override<Key>::policy);
9191 }
9292 pybind11::set s;
9393 for (auto &&value : src) {
9494 auto value_ = reinterpret_steal<object>(
95- key_conv::cast (detail::forward_like<T>(value), policy , parent));
95+ key_conv::cast (detail::forward_like<T>(value), rvpp , parent));
9696 if (!value_ || !s.add (std::move (value_))) {
9797 return handle ();
9898 }
@@ -191,15 +191,15 @@ struct list_caster {
191191
192192public:
193193 template <typename T>
194- static handle cast (T &&src, return_value_policy policy , handle parent) {
194+ static handle cast (T &&src, return_value_policy_pack rvpp , handle parent) {
195195 if (!std::is_lvalue_reference<T>::value) {
196- policy = return_value_policy_override<Value>::policy ( policy);
196+ rvpp = rvpp. override_policy ( return_value_policy_override<Value>::policy);
197197 }
198198 list l (src.size ());
199199 ssize_t index = 0 ;
200200 for (auto &&value : src) {
201201 auto value_ = reinterpret_steal<object>(
202- value_conv::cast (detail::forward_like<T>(value), policy , parent));
202+ value_conv::cast (detail::forward_like<T>(value), rvpp , parent));
203203 if (!value_) {
204204 return handle ();
205205 }
@@ -208,7 +208,7 @@ struct list_caster {
208208 return l.release ();
209209 }
210210
211- PYBIND11_TYPE_CASTER (Type, const_name(" List[" ) + value_conv::name + const_name(" ]" ));
211+ PYBIND11_TYPE_CASTER_RVPP (Type, const_name(" List[" ) + value_conv::name + const_name(" ]" ));
212212};
213213
214214template <typename Type, typename Alloc>
@@ -258,12 +258,12 @@ struct array_caster {
258258 }
259259
260260 template <typename T>
261- static handle cast (T &&src, return_value_policy policy , handle parent) {
261+ static handle cast (T &&src, return_value_policy_pack rvpp , handle parent) {
262262 list l (src.size ());
263263 ssize_t index = 0 ;
264264 for (auto &&value : src) {
265265 auto value_ = reinterpret_steal<object>(
266- value_conv::cast (detail::forward_like<T>(value), policy , parent));
266+ value_conv::cast (detail::forward_like<T>(value), rvpp , parent));
267267 if (!value_) {
268268 return handle ();
269269 }
@@ -272,12 +272,12 @@ struct array_caster {
272272 return l.release ();
273273 }
274274
275- PYBIND11_TYPE_CASTER (ArrayType,
276- const_name (" List[" ) + value_conv::name
277- + const_name<Resizable>(const_name(" " ),
278- const_name(" [" ) + const_name<Size>()
279- + const_name(" ]" ))
280- + const_name(" ]" ));
275+ PYBIND11_TYPE_CASTER_RVPP (ArrayType,
276+ const_name (" List[" ) + value_conv::name
277+ + const_name<Resizable>(const_name(" " ),
278+ const_name(" [" ) + const_name<Size>()
279+ + const_name(" ]" ))
280+ + const_name(" ]" ));
281281};
282282
283283template <typename Type, size_t Size>
@@ -309,15 +309,15 @@ struct optional_caster {
309309 using value_conv = make_caster<Value>;
310310
311311 template <typename T>
312- static handle cast (T &&src, return_value_policy policy , handle parent) {
312+ static handle cast (T &&src, return_value_policy_pack rvpp , handle parent) {
313313 if (!src) {
314314 return none ().release ();
315315 }
316316 if (!std::is_lvalue_reference<T>::value) {
317- policy = return_value_policy_override<Value>::policy ( policy);
317+ rvpp = rvpp. override_policy ( return_value_policy_override<Value>::policy);
318318 }
319319 // NOLINTNEXTLINE(bugprone-unchecked-optional-access)
320- return value_conv::cast (*std::forward<T>(src), policy , parent);
320+ return value_conv::cast (*std::forward<T>(src), rvpp , parent);
321321 }
322322
323323 bool load (handle src, bool convert) {
@@ -336,7 +336,7 @@ struct optional_caster {
336336 return true ;
337337 }
338338
339- PYBIND11_TYPE_CASTER (Type, const_name(" Optional[" ) + value_conv::name + const_name(" ]" ));
339+ PYBIND11_TYPE_CASTER_RVPP (Type, const_name(" Optional[" ) + value_conv::name + const_name(" ]" ));
340340};
341341
342342#if defined(PYBIND11_HAS_OPTIONAL)
@@ -359,14 +359,14 @@ struct type_caster<std::experimental::nullopt_t>
359359
360360// / Visit a variant and cast any found type to Python
361361struct variant_caster_visitor {
362- return_value_policy policy ;
362+ return_value_policy_pack rvpp ;
363363 handle parent;
364364
365365 using result_type = handle; // required by boost::variant in C++11
366366
367367 template <typename T>
368368 result_type operator ()(T &&src) const {
369- return make_caster<T>::cast (std::forward<T>(src), policy , parent);
369+ return make_caster<T>::cast (std::forward<T>(src), rvpp , parent);
370370 }
371371};
372372
@@ -417,15 +417,15 @@ struct variant_caster<V<Ts...>> {
417417 }
418418
419419 template <typename Variant>
420- static handle cast (Variant &&src, return_value_policy policy , handle parent) {
421- return visit_helper<V>::call (variant_caster_visitor{policy , parent},
420+ static handle cast (Variant &&src, return_value_policy_pack rvpp , handle parent) {
421+ return visit_helper<V>::call (variant_caster_visitor{rvpp , parent},
422422 std::forward<Variant>(src));
423423 }
424424
425425 using Type = V<Ts...>;
426- PYBIND11_TYPE_CASTER (Type,
427- const_name (" Union[" ) + detail::concat(make_caster<Ts>::name...)
428- + const_name(" ]" ));
426+ PYBIND11_TYPE_CASTER_RVPP (Type,
427+ const_name (" Union[" ) + detail::concat(make_caster<Ts>::name...)
428+ + const_name(" ]" ));
429429};
430430
431431#if defined(PYBIND11_HAS_VARIANT)
0 commit comments