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) {
                                                  ^
```
This commit is contained in:
Ralf W. Grosse-Kunstleve 2024-07-03 12:54:41 -07:00
parent fc5678b08b
commit af66246fb6

View File

@ -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<std::shared_ptr<type>>();
@ -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 <typename T = std::shared_ptr<type>,