From 783ad8239c03fbb44b3ed2c28282a43f849adafa Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Thu, 23 Dec 2021 12:51:38 +0100 Subject: Format source code to suit clang-format * sigc++/functors/mem_fun.h: * sigc++/functors/ptr_fun.h: * tests/test_rvalue_ref.cc: Reformated with clang-format 13, but CI uses clang-format 10. Also add #include where std::forward was added. Doesn't seem to be necessary with g++ or clang++. Mostly a precaution. --- sigc++/functors/mem_fun.h | 10 ++++++---- sigc++/functors/ptr_fun.h | 7 +++++-- tests/test_rvalue_ref.cc | 8 +++++--- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/sigc++/functors/mem_fun.h b/sigc++/functors/mem_fun.h index 1b74c3d..1ebccbb 100644 --- a/sigc++/functors/mem_fun.h +++ b/sigc++/functors/mem_fun.h @@ -22,6 +22,7 @@ #include #include #include +#include // implementation notes: // - we do not use bind here, because it would introduce @@ -150,8 +151,7 @@ public: decltype(auto) operator()(type_trait_take_t... a) const { return std::invoke( - this->func_ptr_, obj_.invoke(), - std::forward>(a)...); + this->func_ptr_, obj_.invoke(), std::forward>(a)...); } // protected: @@ -187,7 +187,8 @@ struct visitor> * @ingroup mem_fun */ template -inline decltype(auto) mem_fun(T_return (T_obj::*func)(T_arg...)) +inline decltype(auto) +mem_fun(T_return (T_obj::*func)(T_arg...)) { return mem_functor(func); } @@ -212,7 +213,8 @@ mem_fun(T_return (T_obj::*func)(T_arg...) const) * @ingroup mem_fun */ template -inline decltype(auto) mem_fun(T_return (T_obj::*func)(T_arg...) volatile) +inline decltype(auto) +mem_fun(T_return (T_obj::*func)(T_arg...) volatile) { return mem_functor(func); } diff --git a/sigc++/functors/ptr_fun.h b/sigc++/functors/ptr_fun.h index c1dc8b7..b80ccab 100644 --- a/sigc++/functors/ptr_fun.h +++ b/sigc++/functors/ptr_fun.h @@ -20,6 +20,7 @@ #define SIGC_FUNCTORS_PTR_FUN_H #include #include +#include namespace sigc { @@ -92,7 +93,8 @@ public: * @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 { + T_return operator()(type_trait_take_t... a) const + { return std::invoke(func_ptr_, std::forward>(a)...); } }; @@ -104,7 +106,8 @@ public: * @ingroup ptr_fun */ template -inline decltype(auto) ptr_fun(T_return (*func)(T_args...)) +inline decltype(auto) +ptr_fun(T_return (*func)(T_args...)) { return pointer_functor(func); } diff --git a/tests/test_rvalue_ref.cc b/tests/test_rvalue_ref.cc index 4e1666b..344a856 100644 --- a/tests/test_rvalue_ref.cc +++ b/tests/test_rvalue_ref.cc @@ -18,10 +18,12 @@ struct foo struct A { - void foo(MoveableStruct &&) { result_stream << "A::foo(MoveableStruct&&)"; } + void foo(MoveableStruct&&) { result_stream << "A::foo(MoveableStruct&&)"; } }; -void boo(MoveableStruct &&) { +void +boo(MoveableStruct&&) +{ result_stream << "boo(MoveableStruct&&)"; } @@ -52,7 +54,7 @@ test_slot() void test_mem_fun() { - sigc::slot slot; + sigc::slot slot; A a; slot = sigc::mem_fun(&A::foo); MoveableStruct x; -- cgit v1.2.1