Skip to content

Commit 317ab48

Browse files
committed
test_rvalue_ref: Small fixes
* tests/.gitignore: * tests/CMakeLists.txt: * tests/Makefile.am: Add test_rvalue_ref. * tests/test_rvalue_ref.cc: Avoid [-Werror=unused-parameter] when building with warnings=fatal. Some files have been reformated with clang-format in order to make the CI tests happy. Reformated with clang-format 12, but CI uses clang-format 10.
1 parent 070095a commit 317ab48

File tree

6 files changed

+16
-12
lines changed

6 files changed

+16
-12
lines changed

sigc++/functors/slot.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,9 @@ struct slot_call
151151
static T_return call_it(slot_rep* rep, type_trait_take_t<T_arg>... a_)
152152
{
153153
auto typed_rep = static_cast<typed_slot_rep<T_functor>*>(rep);
154-
return (*typed_rep->functor_).template operator()<type_trait_take_t<T_arg>...>(
155-
std::forward<type_trait_take_t<T_arg>>(a_)...);
154+
return (*typed_rep->functor_)
155+
.template operator()<type_trait_take_t<T_arg>...>(
156+
std::forward<type_trait_take_t<T_arg>>(a_)...);
156157
}
157158

158159
/** Forms a function pointer from call_it().

sigc++/signal.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -364,8 +364,7 @@ struct signal_emit<void, void, T_arg...>
364364
continue;
365365

366366
(sigc::internal::function_pointer_cast<call_type>(slot.rep_->call_))(
367-
slot.rep_,
368-
std::forward<type_trait_take_t<T_arg>>(a)...);
367+
slot.rep_, std::forward<type_trait_take_t<T_arg>>(a)...);
369368
}
370369
}
371370
};
@@ -456,7 +455,8 @@ class signal_with_accumulator : public signal_base
456455
}
457456

458457
/** Triggers the emission of the signal (see emit()). */
459-
decltype(auto) operator()(type_trait_take_t<T_arg>... a) const {
458+
decltype(auto) operator()(type_trait_take_t<T_arg>... a) const
459+
{
460460
return emit(std::forward<type_trait_take_t<T_arg>>(a)...);
461461
}
462462

tests/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
/test_ptr_fun
2525
/test_retype
2626
/test_retype_return
27+
/test_rvalue_ref
2728
/test_signal
2829
/test_signal_move
2930
/test_size

tests/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ set (TEST_SOURCE_FILES
3939
test_ptr_fun.cc
4040
test_retype.cc
4141
test_retype_return.cc
42+
test_rvalue_ref.cc
4243
test_signal.cc
4344
test_signal_move.cc
4445
test_size.cc

tests/Makefile.am

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ check_PROGRAMS = \
4646
test_ptr_fun \
4747
test_retype \
4848
test_retype_return \
49+
test_rvalue_ref \
4950
test_signal \
5051
test_signal_move \
5152
test_size \
@@ -90,6 +91,7 @@ test_mem_fun_SOURCES = test_mem_fun.cc $(sigc_test_util)
9091
test_ptr_fun_SOURCES = test_ptr_fun.cc $(sigc_test_util)
9192
test_retype_SOURCES = test_retype.cc $(sigc_test_util)
9293
test_retype_return_SOURCES = test_retype_return.cc $(sigc_test_util)
94+
test_rvalue_ref_SOURCES = test_rvalue_ref.cc $(sigc_test_util)
9395
test_signal_SOURCES = test_signal.cc $(sigc_test_util)
9496
test_signal_move_SOURCES = test_signal_move.cc $(sigc_test_util)
9597
test_size_SOURCES = test_size.cc $(sigc_test_util)

tests/test_rvalue_ref.cc

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
#include <iostream>
33
#include <sigc++/signal.h>
44

5-
struct MoveableStruct {};
5+
struct MoveableStruct
6+
{
7+
};
68

79
namespace
810
{
@@ -11,18 +13,15 @@ std::ostringstream result_stream;
1113

1214
struct foo
1315
{
14-
void operator()(MoveableStruct &&x)
15-
{
16-
result_stream << "foo(MoveableStruct&&)";
17-
}
16+
void operator()(MoveableStruct&& /* x */) { result_stream << "foo(MoveableStruct&&)"; }
1817
};
1918

2019
} // end anonymous namespace
2120

2221
void
2322
test_signal()
2423
{
25-
sigc::signal<void (MoveableStruct &&)> signal;
24+
sigc::signal<void(MoveableStruct &&)> signal;
2625
foo f;
2726
signal.connect(f);
2827
MoveableStruct x;
@@ -33,7 +32,7 @@ test_signal()
3332
void
3433
test_slot()
3534
{
36-
sigc::slot<void (MoveableStruct &&)> slot;
35+
sigc::slot<void(MoveableStruct &&)> slot;
3736
foo f;
3837
slot = f;
3938
MoveableStruct x;

0 commit comments

Comments
 (0)