diff --git a/sigc++/functors/mem_fun.h b/sigc++/functors/mem_fun.h index 65563a3..1b74c3d 100644 --- a/sigc++/functors/mem_fun.h +++ b/sigc++/functors/mem_fun.h @@ -113,7 +113,7 @@ class mem_functor */ decltype(auto) operator()(obj_type_with_modifier& obj, type_trait_take_t... a) const { - return std::invoke(func_ptr_, obj, a...); + return std::invoke(func_ptr_, obj, std::forward>(a)...); } protected: @@ -149,7 +149,9 @@ class bound_mem_functor : mem_functor */ 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/sigc++/functors/ptr_fun.h b/sigc++/functors/ptr_fun.h index 288ac87..c1dc8b7 100644 --- a/sigc++/functors/ptr_fun.h +++ b/sigc++/functors/ptr_fun.h @@ -92,7 +92,9 @@ class pointer_functor * @param a Arguments to be passed on to the function. * @return The return value of the function invocation. */ - T_return operator()(type_trait_take_t... a) const { return std::invoke(func_ptr_, a...); } + T_return operator()(type_trait_take_t... a) const { + return std::invoke(func_ptr_, std::forward>(a)...); + } }; /** Creates a functor of type sigc::pointer_functor which wraps an existing non-member function. diff --git a/tests/test_rvalue_ref.cc b/tests/test_rvalue_ref.cc index 54b04f3..4e1666b 100644 --- a/tests/test_rvalue_ref.cc +++ b/tests/test_rvalue_ref.cc @@ -16,6 +16,15 @@ struct foo void operator()(MoveableStruct&& /* x */) { result_stream << "foo(MoveableStruct&&)"; } }; +struct A +{ + void foo(MoveableStruct &&) { result_stream << "A::foo(MoveableStruct&&)"; } +}; + +void boo(MoveableStruct &&) { + result_stream << "boo(MoveableStruct&&)"; +} + } // end anonymous namespace void @@ -40,6 +49,38 @@ test_slot() util->check_result(result_stream, "foo(MoveableStruct&&)"); } +void +test_mem_fun() +{ + sigc::slot slot; + A a; + slot = sigc::mem_fun(&A::foo); + MoveableStruct x; + slot(a, std::move(x)); + util->check_result(result_stream, "A::foo(MoveableStruct&&)"); +} + +void +test_bound_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&&)"); +} + +void +test_ptr_fun() +{ + sigc::slot slot; + slot = sigc::ptr_fun(&boo); + MoveableStruct x; + slot(std::move(x)); + util->check_result(result_stream, "boo(MoveableStruct&&)"); +} + int main(int argc, char* argv[]) { @@ -49,6 +90,9 @@ main(int argc, char* argv[]) test_signal(); test_slot(); + test_bound_mem_fun(); + test_mem_fun(); + test_ptr_fun(); return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE; } // end main() pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy