Skip to content

Commit 01652fd

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 also 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 7d85510 commit 01652fd

File tree

11 files changed

+34
-28
lines changed

11 files changed

+34
-28
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_bind.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ struct book : public sigc::trackable
7070
book& operator=(book&&) = delete;
7171

7272
std::string& get_name() { return name_; }
73-
operator std::string &() { return get_name(); }
73+
operator std::string&() { return get_name(); }
7474

7575
private:
7676
std::string name_;

tests/test_cpp11_lambda.cc

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ egon(std::string& str)
8888
struct book : public sigc::trackable
8989
{
9090
explicit book(const std::string& name) : name_(name) {}
91-
operator std::string &() { return name_; }
91+
operator std::string&() { return name_; }
9292
std::string name_;
9393
};
9494

@@ -184,8 +184,8 @@ main(int argc, char* argv[])
184184
// See https://bugzilla.gnome.org/show_bug.cgi?id=669128
185185
// std::cout << "((++_1)*2)(ref(a)): " << ((++_1)*2)(std::ref(a));
186186
// std::cout << "; a: " << a << std::endl;
187-
result_stream << ([](std::reference_wrapper<int> x) -> int { return ++x * 2; }(
188-
std::ref(a_outer)));
187+
result_stream << ([](std::reference_wrapper<int> x) -> int
188+
{ return ++x * 2; }(std::ref(a_outer)));
189189
result_stream << " " << a_outer;
190190
util->check_result(result_stream, "4 2");
191191
result_stream << ([](int& x) -> int { return ++x * 2; }(a_outer));
@@ -200,8 +200,8 @@ main(int argc, char* argv[])
200200

201201
// std::cout << "((--(*(&_1)))*2)(ref(a)): " << ((--(*(&_1)))*2)(std::ref(a));
202202
// std::cout << "; a: " << a << std::endl;
203-
result_stream << ([](std::reference_wrapper<int> x) -> int { return --(*(&x)) * 2; }(
204-
std::ref(a_outer)));
203+
result_stream << ([](std::reference_wrapper<int> x) -> int
204+
{ return --(*(&x)) * 2; }(std::ref(a_outer)));
205205
result_stream << " " << a_outer;
206206
util->check_result(result_stream, "6 3");
207207
result_stream << ([](int& x) -> int { return --(*(&x)) * 2; }(a_outer));
@@ -234,8 +234,8 @@ main(int argc, char* argv[])
234234
// std::cout << "(var(c) = (var(a) = _1, var(b) = _2))(2,3): "
235235
// << (sigc::var(c) = (sigc::var(a) = _1, sigc::var(b) = _2))(2,3);
236236
// std::cout << "; a: " << a << "; b: " << b << "; c: " << c << std::endl;
237-
result_stream << ([&a_outer, &b_outer, &c_outer](
238-
int x, int y) -> int { return c_outer = (a_outer = x, b_outer = y); }(2, 3));
237+
result_stream << ([&a_outer, &b_outer, &c_outer](int x, int y) -> int
238+
{ return c_outer = (a_outer = x, b_outer = y); }(2, 3));
239239
result_stream << " " << a_outer << " " << b_outer << " " << c_outer;
240240
util->check_result(result_stream, "3 2 3 3");
241241

tests/test_member_method_trait.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ test_member_method_is_volatile()
6060
sigc::internal::member_method_is_volatile<decltype(&Something::some_volatile_func)>::value,
6161
"member_method_is_const failed to identify a volatile member method.");
6262

63-
static_assert(sigc::internal::member_method_is_volatile<decltype(
64-
&Something::some_const_volatile_func)>::value,
63+
static_assert(sigc::internal::member_method_is_volatile<
64+
decltype(&Something::some_const_volatile_func)>::value,
6565
"member_method_is_const failed to identify a volatile member method.");
6666
}
6767

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;

tests/test_signal.cc

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,12 @@ test_clear_called_in_signal_handler()
117117
{
118118
sigc::signal<void()> sig;
119119
sig.connect([]() { result_stream << ", slot 1, "; });
120-
sig.connect([&sig]() {
121-
sig.clear();
122-
result_stream << "slot 2, ";
123-
});
120+
sig.connect(
121+
[&sig]()
122+
{
123+
sig.clear();
124+
result_stream << "slot 2, ";
125+
});
124126
sig.connect([]() { result_stream << "slot 3, "; });
125127
result_stream << sig.size();
126128
sig.emit();

tests/test_track_obj.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ std::ostringstream result_stream;
4040
struct book : public sigc::trackable
4141
{
4242
explicit book(const std::string& name) : name_(name) {}
43-
operator std::string &() { return name_; }
44-
operator const std::string &() const { return name_; }
43+
operator std::string&() { return name_; }
44+
operator const std::string&() const { return name_; }
4545
std::string name_;
4646
};
4747

0 commit comments

Comments
 (0)