From f123a0d5ed4534a1f15e7fcce52f62765349bdf4 Mon Sep 17 00:00:00 2001 From: David Stone Date: Wed, 9 Oct 2024 19:27:25 -0600 Subject: [PATCH] `function_ref` should not always reference qualify parameters By accepting `Args&&...`, a function that accepts its arguments by value is required to accept only rvalues. Instead, we should accept `Args...` (the exact argument types listed in the signature), which allows by-value parameters to copy from lvalue arguments. --- include/boost/compat/function_ref.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/compat/function_ref.hpp b/include/boost/compat/function_ref.hpp index 701bb15..2838ce1 100644 --- a/include/boost/compat/function_ref.hpp +++ b/include/boost/compat/function_ref.hpp @@ -131,7 +131,7 @@ struct function_ref_base { function_ref_base(const function_ref_base&) noexcept = default; function_ref_base& operator=(const function_ref_base&) noexcept = default; - R operator()(Args&&... args) const noexcept(NoEx) { return this->invoke_(thunk_, std::forward(args)...); } + R operator()(Args... args) const noexcept(NoEx) { return this->invoke_(thunk_, std::forward(args)...); } }; } // namespace detail