Use rvalue reference for std::variant cast_op<T> (#3811)

Nearly every call site of cast_op<T> uses an r-value reference.

Except stl.h variant_caster::load_alternative for handling std::variant.

Fix that.
This commit is contained in:
Laramie Leavitt 2022-03-18 11:10:31 -07:00 committed by GitHub
parent 8b1944d390
commit b3a43d137c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -372,7 +372,7 @@ struct variant_caster<V<Ts...>> {
bool load_alternative(handle src, bool convert, type_list<U, Us...>) { bool load_alternative(handle src, bool convert, type_list<U, Us...>) {
auto caster = make_caster<U>(); auto caster = make_caster<U>();
if (caster.load(src, convert)) { if (caster.load(src, convert)) {
value = cast_op<U>(caster); value = cast_op<U>(std::move(caster));
return true; return true;
} }
return load_alternative(src, convert, type_list<Us...>{}); return load_alternative(src, convert, type_list<Us...>{});