From a4883790100b0da6f777ec154a525389f776a3c7 Mon Sep 17 00:00:00 2001 From: Slava Andrejev Date: Sun, 19 Dec 2021 22:25:46 -0800 Subject: Add missing perfect forwarding in bound_mem_functor::operator() This is a missed addition to the commit that allowed rvalue references in slot parameters. --- sigc++/functors/mem_fun.h | 4 +++- tests/test_rvalue_ref.cc | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/sigc++/functors/mem_fun.h b/sigc++/functors/mem_fun.h index 65563a3..e3327fb 100644 --- a/sigc++/functors/mem_fun.h +++ b/sigc++/functors/mem_fun.h @@ -149,7 +149,9 @@ public: */ decltype(auto) operator()(type_trait_take_t... a) const { - return std::invoke(this->func_ptr_, obj_.invoke(), a...); + return std::invoke( + this->func_ptr_, obj_.invoke(), + std::forward>(a)...); } // protected: diff --git a/tests/test_rvalue_ref.cc b/tests/test_rvalue_ref.cc index 54b04f3..ec81d39 100644 --- a/tests/test_rvalue_ref.cc +++ b/tests/test_rvalue_ref.cc @@ -16,6 +16,12 @@ struct foo void operator()(MoveableStruct&& /* x */) { result_stream << "foo(MoveableStruct&&)"; } }; +struct A +{ + void foo(MoveableStruct &&) { result_stream << "A::foo(MoveableStruct&&)"; } +}; + + } // end anonymous namespace void @@ -40,6 +46,17 @@ test_slot() util->check_result(result_stream, "foo(MoveableStruct&&)"); } +void +test_mem_fun() +{ + sigc::slot slot; + A a; + slot = sigc::mem_fun(a, &A::foo); + MoveableStruct x; + slot(std::move(x)); + util->check_result(result_stream, "A::foo(MoveableStruct&&)"); +} + int main(int argc, char* argv[]) { @@ -49,6 +66,7 @@ main(int argc, char* argv[]) test_signal(); test_slot(); + test_mem_fun(); return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE; } // end main() -- cgit v1.2.1