diff options
author | Kjell Ahlstedt <kjellahlstedt@gmail.com> | 2021-06-02 22:36:35 +0200 |
---|---|---|
committer | Kjell Ahlstedt <kjellahlstedt@gmail.com> | 2021-06-02 22:36:35 +0200 |
commit | 317ab48ceb0a416c56c41b091a3769ccf2880ba8 (patch) | |
tree | 91b9bcb4a88dab986624a05bebc8419dbc4c1386 | |
parent | 070095a6addddea72b04cebe7479698082ac1419 (diff) | |
download | sigc++-317ab48ceb0a416c56c41b091a3769ccf2880ba8.tar.gz |
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.
-rw-r--r-- | sigc++/functors/slot.h | 5 | ||||
-rw-r--r-- | sigc++/signal.h | 6 | ||||
-rw-r--r-- | tests/.gitignore | 1 | ||||
-rw-r--r-- | tests/CMakeLists.txt | 1 | ||||
-rw-r--r-- | tests/Makefile.am | 2 | ||||
-rw-r--r-- | tests/test_rvalue_ref.cc | 13 |
6 files changed, 16 insertions, 12 deletions
diff --git a/sigc++/functors/slot.h b/sigc++/functors/slot.h index 8e9e01a..e368e86 100644 --- a/sigc++/functors/slot.h +++ b/sigc++/functors/slot.h @@ -151,8 +151,9 @@ struct slot_call static T_return call_it(slot_rep* rep, type_trait_take_t<T_arg>... a_) { auto typed_rep = static_cast<typed_slot_rep<T_functor>*>(rep); - return (*typed_rep->functor_).template operator()<type_trait_take_t<T_arg>...>( - std::forward<type_trait_take_t<T_arg>>(a_)...); + return (*typed_rep->functor_) + .template operator()<type_trait_take_t<T_arg>...>( + std::forward<type_trait_take_t<T_arg>>(a_)...); } /** Forms a function pointer from call_it(). diff --git a/sigc++/signal.h b/sigc++/signal.h index 336bd5f..c1b0f33 100644 --- a/sigc++/signal.h +++ b/sigc++/signal.h @@ -364,8 +364,7 @@ public: continue; (sigc::internal::function_pointer_cast<call_type>(slot.rep_->call_))( - slot.rep_, - std::forward<type_trait_take_t<T_arg>>(a)...); + slot.rep_, std::forward<type_trait_take_t<T_arg>>(a)...); } } }; @@ -456,7 +455,8 @@ public: } /** Triggers the emission of the signal (see emit()). */ - decltype(auto) operator()(type_trait_take_t<T_arg>... a) const { + decltype(auto) operator()(type_trait_take_t<T_arg>... a) const + { return emit(std::forward<type_trait_take_t<T_arg>>(a)...); } diff --git a/tests/.gitignore b/tests/.gitignore index 276abe2..0a788ab 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -24,6 +24,7 @@ /test_ptr_fun /test_retype /test_retype_return +/test_rvalue_ref /test_signal /test_signal_move /test_size diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 36e728b..9485b45 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -39,6 +39,7 @@ set (TEST_SOURCE_FILES test_ptr_fun.cc test_retype.cc test_retype_return.cc + test_rvalue_ref.cc test_signal.cc test_signal_move.cc test_size.cc diff --git a/tests/Makefile.am b/tests/Makefile.am index 735d76b..b05f7b4 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -46,6 +46,7 @@ check_PROGRAMS = \ test_ptr_fun \ test_retype \ test_retype_return \ + test_rvalue_ref \ test_signal \ test_signal_move \ test_size \ @@ -90,6 +91,7 @@ test_mem_fun_SOURCES = test_mem_fun.cc $(sigc_test_util) test_ptr_fun_SOURCES = test_ptr_fun.cc $(sigc_test_util) test_retype_SOURCES = test_retype.cc $(sigc_test_util) test_retype_return_SOURCES = test_retype_return.cc $(sigc_test_util) +test_rvalue_ref_SOURCES = test_rvalue_ref.cc $(sigc_test_util) test_signal_SOURCES = test_signal.cc $(sigc_test_util) test_signal_move_SOURCES = test_signal_move.cc $(sigc_test_util) test_size_SOURCES = test_size.cc $(sigc_test_util) diff --git a/tests/test_rvalue_ref.cc b/tests/test_rvalue_ref.cc index b35ace1..54b04f3 100644 --- a/tests/test_rvalue_ref.cc +++ b/tests/test_rvalue_ref.cc @@ -2,7 +2,9 @@ #include <iostream> #include <sigc++/signal.h> -struct MoveableStruct {}; +struct MoveableStruct +{ +}; namespace { @@ -11,10 +13,7 @@ std::ostringstream result_stream; struct foo { - void operator()(MoveableStruct &&x) - { - result_stream << "foo(MoveableStruct&&)"; - } + void operator()(MoveableStruct&& /* x */) { result_stream << "foo(MoveableStruct&&)"; } }; } // end anonymous namespace @@ -22,7 +21,7 @@ struct foo void test_signal() { - sigc::signal<void (MoveableStruct &&)> signal; + sigc::signal<void(MoveableStruct &&)> signal; foo f; signal.connect(f); MoveableStruct x; @@ -33,7 +32,7 @@ test_signal() void test_slot() { - sigc::slot<void (MoveableStruct &&)> slot; + sigc::slot<void(MoveableStruct &&)> slot; foo f; slot = f; MoveableStruct x; |