From b3a43d137c6c9ecf271a2a3d51a51b2fd1c3e8f6 Mon Sep 17 00:00:00 2001 From: Laramie Leavitt Date: Fri, 18 Mar 2022 11:10:31 -0700 Subject: [PATCH] Use rvalue reference for std::variant cast_op (#3811) Nearly every call site of cast_op uses an r-value reference. Except stl.h variant_caster::load_alternative for handling std::variant. Fix that. --- include/pybind11/stl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/pybind11/stl.h b/include/pybind11/stl.h index b66129688..e3a061444 100644 --- a/include/pybind11/stl.h +++ b/include/pybind11/stl.h @@ -372,7 +372,7 @@ struct variant_caster> { bool load_alternative(handle src, bool convert, type_list) { auto caster = make_caster(); if (caster.load(src, convert)) { - value = cast_op(caster); + value = cast_op(std::move(caster)); return true; } return load_alternative(src, convert, type_list{});