summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSlava Andrejev <vyac.andrejev@gmail.com>2021-12-19 22:25:46 -0800
committerKjell Ahlstedt <kjellahlstedt@gmail.com>2021-12-23 10:18:18 +0100
commita4883790100b0da6f777ec154a525389f776a3c7 (patch)
treea481a6f4fb28692724736e44479b21a59c08d4d9
parentaf16bf0d15782345ce41323706a3dcc6c06ce253 (diff)
downloadsigc++-a4883790100b0da6f777ec154a525389f776a3c7.tar.gz
Add missing perfect forwarding in bound_mem_functor::operator()
This is a missed addition to the commit that allowed rvalue references in slot parameters.
-rw-r--r--sigc++/functors/mem_fun.h4
-rw-r--r--tests/test_rvalue_ref.cc18
2 files changed, 21 insertions, 1 deletions
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<T_arg>... a) const
{
- return std::invoke(this->func_ptr_, obj_.invoke(), a...);
+ return std::invoke(
+ this->func_ptr_, obj_.invoke(),
+ std::forward<type_trait_take_t<T_arg>>(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<void(MoveableStruct &&)> 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()