Skip to content

Commit a488379

Browse files
slavaandrejevkjellahl
authored andcommitted
Add missing perfect forwarding in bound_mem_functor::operator()
This is a missed addition to the commit that allowed rvalue references in slot parameters.
1 parent af16bf0 commit a488379

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

sigc++/functors/mem_fun.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,9 @@ class bound_mem_functor : mem_functor<T_func, T_arg...>
149149
*/
150150
decltype(auto) operator()(type_trait_take_t<T_arg>... a) const
151151
{
152-
return std::invoke(this->func_ptr_, obj_.invoke(), a...);
152+
return std::invoke(
153+
this->func_ptr_, obj_.invoke(),
154+
std::forward<type_trait_take_t<T_arg>>(a)...);
153155
}
154156

155157
// protected:

tests/test_rvalue_ref.cc

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ struct foo
1616
void operator()(MoveableStruct&& /* x */) { result_stream << "foo(MoveableStruct&&)"; }
1717
};
1818

19+
struct A
20+
{
21+
void foo(MoveableStruct &&) { result_stream << "A::foo(MoveableStruct&&)"; }
22+
};
23+
24+
1925
} // end anonymous namespace
2026

2127
void
@@ -40,6 +46,17 @@ test_slot()
4046
util->check_result(result_stream, "foo(MoveableStruct&&)");
4147
}
4248

49+
void
50+
test_mem_fun()
51+
{
52+
sigc::slot<void(MoveableStruct &&)> slot;
53+
A a;
54+
slot = sigc::mem_fun(a, &A::foo);
55+
MoveableStruct x;
56+
slot(std::move(x));
57+
util->check_result(result_stream, "A::foo(MoveableStruct&&)");
58+
}
59+
4360
int
4461
main(int argc, char* argv[])
4562
{
@@ -49,6 +66,7 @@ main(int argc, char* argv[])
4966

5067
test_signal();
5168
test_slot();
69+
test_mem_fun();
5270

5371
return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;
5472
} // end main()

0 commit comments

Comments
 (0)
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