From af66246fb61f391196a490892e3ee43fa164d3b0 Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Wed, 3 Jul 2024 12:54:41 -0700 Subject: [PATCH] Resolve clang-tidy errors: ``` /__w/pybind11/pybind11/include/pybind11/cast.h:918:44: error: std::move of the variable 'v_h' of the trivially-copyable type 'pybind11::detail::value_and_holder' has no effect [performance-move-const-arg,-warnings-as-errors] return load_value_smart_holder(std::move(v_h)); ^ /__w/pybind11/pybind11/include/pybind11/cast.h:911:53: note: consider changing the 1st parameter of 'load_value_smart_holder' from 'pybind11::detail::value_and_holder &&' to 'const pybind11::detail::value_and_holder &' bool load_value_smart_holder(value_and_holder &&v_h) { ^ /__w/pybind11/pybind11/include/pybind11/cast.h:920:38: error: std::move of the variable 'v_h' of the trivially-copyable type 'pybind11::detail::value_and_holder' has no effect [performance-move-const-arg,-warnings-as-errors] return load_value_shared_ptr(std::move(v_h)); ^ /__w/pybind11/pybind11/include/pybind11/cast.h:895:51: note: consider changing the 1st parameter of 'load_value_shared_ptr' from 'pybind11::detail::value_and_holder &&' to 'const pybind11::detail::value_and_holder &' bool load_value_shared_ptr(value_and_holder &&v_h) { ^ ``` --- include/pybind11/cast.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/pybind11/cast.h b/include/pybind11/cast.h index e0fee7557..cdbdad5d8 100644 --- a/include/pybind11/cast.h +++ b/include/pybind11/cast.h @@ -892,7 +892,7 @@ protected: friend class type_caster_generic; void check_holder_compat() {} - bool load_value_shared_ptr(value_and_holder &&v_h) { + bool load_value_shared_ptr(const value_and_holder &v_h) { if (v_h.holder_constructed()) { value = v_h.value_ptr(); shared_ptr_holder = v_h.template holder>(); @@ -908,16 +908,16 @@ protected: #endif } - bool load_value_smart_holder(value_and_holder &&v_h) { + bool load_value_smart_holder(const value_and_holder &v_h) { loaded_v_h = v_h; return true; } bool load_value(value_and_holder &&v_h) { if (typeinfo->default_holder) { - return load_value_smart_holder(std::move(v_h)); + return load_value_smart_holder(v_h); } - return load_value_shared_ptr(std::move(v_h)); + return load_value_shared_ptr(v_h); } template ,