diff options
author | Murray Cumming <murrayc@murrayc.com> | 2019-10-28 12:16:22 +0100 |
---|---|---|
committer | Murray Cumming <murrayc@murrayc.com> | 2019-10-28 12:26:02 +0100 |
commit | 294ce7177c5315e2ada29acd184900dcda4289c8 (patch) | |
tree | c114ef20e9689f8dedcedc700a66f0936a69ba3c /sigc++ | |
parent | 8d747d775ae9da0a7703d28333dc326d81b36120 (diff) | |
download | sigc++-294ce7177c5315e2ada29acd184900dcda4289c8.tar.gz |
Reformat code with make format
Diffstat (limited to 'sigc++')
34 files changed, 381 insertions, 410 deletions
diff --git a/sigc++/adaptors/adaptor_trait.h b/sigc++/adaptors/adaptor_trait.h index fe7f3e7..34ef401 100644 --- a/sigc++/adaptors/adaptor_trait.h +++ b/sigc++/adaptors/adaptor_trait.h @@ -82,7 +82,7 @@ namespace sigc * * @ingroup adaptors */ -template <typename T_functor> +template<typename T_functor> struct adaptor_functor : public adaptor_base { /** Invokes the wrapped functor passing on the arguments. @@ -94,7 +94,7 @@ struct adaptor_functor : public adaptor_base * @param arg Arguments to be passed on to the functor. * @return The return value of the functor invocation. */ - template <typename... T_arg> + template<typename... T_arg> decltype(auto) operator()(T_arg&&... arg) const { return std::invoke(functor_, std::forward<T_arg>(arg)...); @@ -112,7 +112,7 @@ struct adaptor_functor : public adaptor_base * function pointer. * @param type Pointer to function or class method to invoke from operator()(). */ - template <typename T_type> + template<typename T_type> explicit adaptor_functor(const T_type& type) : functor_(type) { } @@ -129,10 +129,10 @@ struct adaptor_functor : public adaptor_base * * @ingroup adaptors */ -template <typename T_functor> +template<typename T_functor> struct visitor<adaptor_functor<T_functor>> { - template <typename T_action> + template<typename T_action> static void do_visit_each(const T_action& action, const adaptor_functor<T_functor>& target) { sigc::visit_each(action, target.functor_); @@ -149,15 +149,14 @@ struct visitor<adaptor_functor<T_functor>> * * @ingroup adaptors */ -template <typename T_functor, bool I_isadaptor = std::is_base_of<adaptor_base, T_functor>::value> +template<typename T_functor, bool I_isadaptor = std::is_base_of<adaptor_base, T_functor>::value> struct adaptor_trait; - /** Trait that specifies the adaptor version of a functor type. * This template specialization is used for types that inherit from adaptor_base. * adaptor_type is equal to @p T_functor in this case. */ -template <typename T_functor> +template<typename T_functor> struct adaptor_trait<T_functor, true> { using adaptor_type = T_functor; @@ -169,7 +168,7 @@ struct adaptor_trait<T_functor, true> * The latter are converted into @p pointer_functor or @p mem_functor types. * adaptor_type is equal to @p adaptor_functor<functor_type>. */ -template <typename T_functor> +template<typename T_functor> struct adaptor_trait<T_functor, false> { private: diff --git a/sigc++/adaptors/adapts.h b/sigc++/adaptors/adapts.h index 959f152..08ae002 100644 --- a/sigc++/adaptors/adapts.h +++ b/sigc++/adaptors/adapts.h @@ -91,7 +91,7 @@ namespace sigc * * @ingroup adaptors */ -template <typename T_functor> +template<typename T_functor> struct adapts : public adaptor_base { private: diff --git a/sigc++/adaptors/bind.h b/sigc++/adaptors/bind.h index 7c187d1..1d89ba0 100644 --- a/sigc++/adaptors/bind.h +++ b/sigc++/adaptors/bind.h @@ -102,7 +102,7 @@ namespace sigc namespace internal { -template <typename T_element> +template<typename T_element> struct TransformEachInvoker { // We take T_element as non-const because invoke() is not const. @@ -122,7 +122,7 @@ struct TransformEachInvoker * * @ingroup bind */ -template <int I_location, typename T_functor, typename... T_bound> +template<int I_location, typename T_functor, typename... T_bound> struct bind_functor : public adapts<T_functor> { /** Invokes the wrapped functor passing on the arguments. @@ -130,7 +130,7 @@ struct bind_functor : public adapts<T_functor> * @param arg Arguments to be passed on to the functor. * @return The return value of the functor invocation. */ - template <typename... T_arg> + template<typename... T_arg> decltype(auto) operator()(T_arg&&... arg) { // For instance, if I_location is 1, and arg has 4 arguments, @@ -171,7 +171,7 @@ struct bind_functor : public adapts<T_functor> * * @ingroup bind */ -template <typename T_functor, typename... T_type> +template<typename T_functor, typename... T_type> struct bind_functor<-1, T_functor, T_type...> : public adapts<T_functor> { public: @@ -180,7 +180,7 @@ public: * @param arg Arguments to be passed on to the functor. * @return The return value of the functor invocation. */ - template <typename... T_arg> + template<typename... T_arg> decltype(auto) operator()(T_arg&&... arg) { // For instance, if arg has 4 arguments, @@ -215,12 +215,12 @@ public: * * @ingroup bind */ -template <int T_loc, typename T_functor, typename... T_bound> +template<int T_loc, typename T_functor, typename... T_bound> struct visitor<bind_functor<T_loc, T_functor, T_bound...>> { - template <typename T_action> - static void do_visit_each( - const T_action& action, const bind_functor<T_loc, T_functor, T_bound...>& target) + template<typename T_action> + static void do_visit_each(const T_action& action, + const bind_functor<T_loc, T_functor, T_bound...>& target) { sigc::visit_each(action, target.functor_); sigc::visit_each(action, std::get<0>(target.bound_)); @@ -234,12 +234,12 @@ struct visitor<bind_functor<T_loc, T_functor, T_bound...>> * * @ingroup bind */ -template <typename T_functor, typename... T_type> +template<typename T_functor, typename... T_type> struct visitor<bind_functor<-1, T_functor, T_type...>> { - template <typename T_action> - static void do_visit_each( - const T_action& action, const bind_functor<-1, T_functor, T_type...>& target) + template<typename T_action> + static void do_visit_each(const T_action& action, + const bind_functor<-1, T_functor, T_type...>& target) { sigc::visit_each(action, target.functor_); @@ -260,7 +260,7 @@ struct visitor<bind_functor<-1, T_functor, T_type...>> * * @ingroup bind */ -template <int I_location, typename T_functor, typename... T_bound> +template<int I_location, typename T_functor, typename... T_bound> inline decltype(auto) bind(const T_functor& func, T_bound... b) { @@ -277,7 +277,7 @@ bind(const T_functor& func, T_bound... b) * * @ingroup bind */ -template <typename T_functor, typename... T_type> +template<typename T_functor, typename... T_type> inline decltype(auto) bind(const T_functor& func, T_type... b) { diff --git a/sigc++/adaptors/bind_return.h b/sigc++/adaptors/bind_return.h index cb5a26a..b02f936 100644 --- a/sigc++/adaptors/bind_return.h +++ b/sigc++/adaptors/bind_return.h @@ -34,7 +34,7 @@ namespace sigc * * @ingroup bind */ -template <typename T_return, typename T_functor> +template<typename T_return, typename T_functor> struct bind_return_functor : public adapts<T_functor> { /** Invokes the wrapped functor dropping its return value. @@ -46,7 +46,7 @@ struct bind_return_functor : public adapts<T_functor> * @param a Arguments to be passed on to the functor. * @return The fixed return value. */ - template <typename... T_arg> + template<typename... T_arg> inline typename unwrap_reference<T_return>::type operator()(T_arg... a) { std::invoke(this->functor_, a...); @@ -57,8 +57,7 @@ struct bind_return_functor : public adapts<T_functor> * @param functor Functor to invoke from operator()(). * @param ret_value Value to return from operator()(). */ - bind_return_functor( - type_trait_take_t<T_functor> functor, type_trait_take_t<T_return> ret_value) + bind_return_functor(type_trait_take_t<T_functor> functor, type_trait_take_t<T_return> ret_value) : adapts<T_functor>(functor), ret_value_(ret_value) { } @@ -67,7 +66,7 @@ struct bind_return_functor : public adapts<T_functor> bound_argument<T_return> ret_value_; // public, so that visit_each() can access it }; -template <typename T_return, typename T_functor> +template<typename T_return, typename T_functor> typename unwrap_reference<T_return>::type bind_return_functor<T_return, T_functor>::operator()() { @@ -83,12 +82,12 @@ bind_return_functor<T_return, T_functor>::operator()() * * @ingroup bind */ -template <typename T_return, typename T_functor> +template<typename T_return, typename T_functor> struct visitor<bind_return_functor<T_return, T_functor>> { - template <typename T_action> - static void do_visit_each( - const T_action& action, const bind_return_functor<T_return, T_functor>& target) + template<typename T_action> + static void do_visit_each(const T_action& action, + const bind_return_functor<T_return, T_functor>& target) { sigc::visit_each(action, target.ret_value_); sigc::visit_each(action, target.functor_); @@ -105,7 +104,7 @@ struct visitor<bind_return_functor<T_return, T_functor>> * * @ingroup bind */ -template <typename T_return, typename T_functor> +template<typename T_return, typename T_functor> inline bind_return_functor<T_return, T_functor> bind_return(const T_functor& functor, T_return ret_value) { diff --git a/sigc++/adaptors/bound_argument.h b/sigc++/adaptors/bound_argument.h index a0ca6da..c9899df 100644 --- a/sigc++/adaptors/bound_argument.h +++ b/sigc++/adaptors/bound_argument.h @@ -46,7 +46,7 @@ namespace sigc * The general template implementation is used for parameters that are passed by value. * @e T_type The type of the bound argument. */ -template <typename T_type> +template<typename T_type> class bound_argument { public: @@ -76,17 +76,14 @@ private: * returned by bind_return() by reference, specialized for std::reference_wrapper<> types. * @e T_wrapped The type of the bound argument. */ -template <typename T_wrapped> +template<typename T_wrapped> class bound_argument<std::reference_wrapper<T_wrapped>> { public: /** Constructor. * @param arg The argument to bind. */ - bound_argument(const std::reference_wrapper<T_wrapped>& arg) - : visited_(unwrap(arg)) - { - } + bound_argument(const std::reference_wrapper<T_wrapped>& arg) : visited_(unwrap(arg)) {} /** Retrieve the entity to visit in visit_each(). * @return The limited_reference to the bound argument. @@ -108,17 +105,14 @@ private: * returned by bind_return() by const reference, specialized for const reference_wrapper<> types. * - @e T_wrapped The type of the bound argument. */ -template <typename T_wrapped> +template<typename T_wrapped> class bound_argument<std::reference_wrapper<const T_wrapped>> { public: /** Constructor. * @param arg The argument to bind. */ - bound_argument(const std::reference_wrapper<const T_wrapped>& arg) - : visited_(unwrap(arg)) - { - } + bound_argument(const std::reference_wrapper<const T_wrapped>& arg) : visited_(unwrap(arg)) {} /** Retrieve the entity to visit in visit_each(). * @return The const_limited_reference to the bound argument. @@ -145,10 +139,10 @@ private: * @param action The functor to invoke. * @param arg The visited instance. */ -template <typename T_type> +template<typename T_type> struct visitor<bound_argument<T_type>> { - template <typename T_action> + template<typename T_action> static void do_visit_each(const T_action& action, const bound_argument<T_type>& arg) { sigc::visit_each(action, arg.visit()); diff --git a/sigc++/adaptors/compose.h b/sigc++/adaptors/compose.h index 5a3616f..3fadceb 100644 --- a/sigc++/adaptors/compose.h +++ b/sigc++/adaptors/compose.h @@ -59,10 +59,10 @@ namespace sigc * * @ingroup compose */ -template <typename T_setter, typename T_getter> +template<typename T_setter, typename T_getter> struct compose1_functor : public adapts<T_setter> { - template <typename... T_arg> + template<typename... T_arg> decltype(auto) operator()(T_arg&&... a) { return std::invoke(this->functor_, get_(std::forward<T_arg>(a)...)); @@ -91,10 +91,10 @@ struct compose1_functor : public adapts<T_setter> * * @ingroup compose */ -template <typename T_setter, typename T_getter1, typename T_getter2> +template<typename T_setter, typename T_getter1, typename T_getter2> struct compose2_functor : public adapts<T_setter> { - template <typename... T_arg> + template<typename... T_arg> decltype(auto) operator()(T_arg... a) { return std::invoke(this->functor_, get1_(a...), get2_(a...)); @@ -106,8 +106,7 @@ struct compose2_functor : public adapts<T_setter> * @param getter1 Functor to invoke from operator()(). * @param getter2 Functor to invoke from operator()(). */ - compose2_functor( - const T_setter& setter, const T_getter1& getter1, const T_getter2& getter2) + compose2_functor(const T_setter& setter, const T_getter1& getter1, const T_getter2& getter2) : adapts<T_setter>(setter), get1_(getter1), get2_(getter2) { } @@ -124,12 +123,12 @@ struct compose2_functor : public adapts<T_setter> * * @ingroup compose */ -template <typename T_setter, typename T_getter> +template<typename T_setter, typename T_getter> struct visitor<compose1_functor<T_setter, T_getter>> { - template <typename T_action> - static void do_visit_each( - const T_action& action, const compose1_functor<T_setter, T_getter>& target) + template<typename T_action> + static void do_visit_each(const T_action& action, + const compose1_functor<T_setter, T_getter>& target) { sigc::visit_each(action, target.functor_); sigc::visit_each(action, target.get_); @@ -143,12 +142,12 @@ struct visitor<compose1_functor<T_setter, T_getter>> * * @ingroup compose */ -template <typename T_setter, typename T_getter1, typename T_getter2> +template<typename T_setter, typename T_getter1, typename T_getter2> struct visitor<compose2_functor<T_setter, T_getter1, T_getter2>> { - template <typename T_action> - static void do_visit_each( - const T_action& action, const compose2_functor<T_setter, T_getter1, T_getter2>& target) + template<typename T_action> + static void do_visit_each(const T_action& action, + const compose2_functor<T_setter, T_getter1, T_getter2>& target) { sigc::visit_each(action, target.functor_); sigc::visit_each(action, target.get1_); @@ -166,7 +165,7 @@ struct visitor<compose2_functor<T_setter, T_getter1, T_getter2>> * * @ingroup compose */ -template <typename T_setter, typename T_getter> +template<typename T_setter, typename T_getter> inline compose1_functor<T_setter, T_getter> compose(const T_setter& setter, const T_getter& getter) { @@ -184,7 +183,7 @@ compose(const T_setter& setter, const T_getter& getter) * * @ingroup compose */ -template <typename T_setter, typename T_getter1, typename T_getter2> +template<typename T_setter, typename T_getter1, typename T_getter2> inline compose2_functor<T_setter, T_getter1, T_getter2> compose(const T_setter& setter, const T_getter1& getter1, const T_getter2& getter2) { diff --git a/sigc++/adaptors/exception_catch.h b/sigc++/adaptors/exception_catch.h index ed60d0c..a7ccf9a 100644 --- a/sigc++/adaptors/exception_catch.h +++ b/sigc++/adaptors/exception_catch.h @@ -73,7 +73,7 @@ namespace sigc * @ingroup adaptors */ -template <typename T_functor, typename T_catcher> +template<typename T_functor, typename T_catcher> struct exception_catch_functor : public adapts<T_functor> { decltype(auto) operator()() @@ -88,7 +88,7 @@ struct exception_catch_functor : public adapts<T_functor> } } - template <typename... T_arg> + template<typename... T_arg> decltype(auto) operator()(T_arg... a) { try @@ -111,10 +111,10 @@ struct exception_catch_functor : public adapts<T_functor> #ifndef DOXYGEN_SHOULD_SKIP_THIS // template specialization of visitor<>::do_visit_each<>(action, functor): -template <typename T_functor, typename T_catcher> +template<typename T_functor, typename T_catcher> struct visitor<exception_catch_functor<T_functor, T_catcher>> { - template <typename T_action> + template<typename T_action> static void do_visit_each(const T_action& action, const exception_catch_functor<T_functor, T_catcher>& target) { @@ -124,7 +124,7 @@ struct visitor<exception_catch_functor<T_functor, T_catcher>> }; #endif // DOXYGEN_SHOULD_SKIP_THIS -template <typename T_functor, typename T_catcher> +template<typename T_functor, typename T_catcher> inline decltype(auto) exception_catch(const T_functor& func, const T_catcher& catcher) { diff --git a/sigc++/adaptors/hide.h b/sigc++/adaptors/hide.h index 8d9d145..ac8a1a0 100644 --- a/sigc++/adaptors/hide.h +++ b/sigc++/adaptors/hide.h @@ -84,14 +84,14 @@ namespace sigc * * @ingroup hide */ -template <int I_location, typename T_functor> +template<int I_location, typename T_functor> struct hide_functor : public adapts<T_functor> { /** Invokes the wrapped functor, ignoring the argument at index @e I_location (0-indexed). * @param a Arguments to be passed on to the functor, apart from the ignored argument. * @return The return value of the functor invocation. */ - template <typename... T_arg> + template<typename... T_arg> decltype(auto) operator()(T_arg&&... a) { constexpr auto size = sizeof...(T_arg); @@ -119,12 +119,12 @@ struct hide_functor : public adapts<T_functor> * * @ingroup hide */ -template <int I_location, typename T_functor> +template<int I_location, typename T_functor> struct visitor<hide_functor<I_location, T_functor>> { - template <typename T_action> - static void do_visit_each( - const T_action& action, const hide_functor<I_location, T_functor>& target) + template<typename T_action> + static void do_visit_each(const T_action& action, + const hide_functor<I_location, T_functor>& target) { sigc::visit_each(action, target.functor_); } @@ -141,7 +141,7 @@ struct visitor<hide_functor<I_location, T_functor>> * * @ingroup hide */ -template <int I_location, typename T_functor> +template<int I_location, typename T_functor> inline decltype(auto) hide(const T_functor& func) { @@ -157,7 +157,7 @@ hide(const T_functor& func) * * @ingroup hide */ -template <typename T_functor> +template<typename T_functor> inline decltype(auto) hide(const T_functor& func) { diff --git a/sigc++/adaptors/retype.h b/sigc++/adaptors/retype.h index a628f95..948fe5c 100644 --- a/sigc++/adaptors/retype.h +++ b/sigc++/adaptors/retype.h @@ -76,10 +76,10 @@ namespace sigc * * @ingroup retype */ -template <typename T_functor, typename... T_type> +template<typename T_functor, typename... T_type> struct retype_functor : public adapts<T_functor> { - template <typename... T_arg> + template<typename... T_arg> decltype(auto) operator()(T_arg... a) { return std::invoke(this->functor_, static_cast<T_type>(a)...); @@ -89,9 +89,7 @@ struct retype_functor : public adapts<T_functor> * the functor. * @param functor Functor to invoke from operator()(). */ - explicit retype_functor(type_trait_take_t<T_functor> functor) : adapts<T_functor>(functor) - { - } + explicit retype_functor(type_trait_take_t<T_functor> functor) : adapts<T_functor>(functor) {} }; #ifndef DOXYGEN_SHOULD_SKIP_THIS @@ -102,12 +100,12 @@ struct retype_functor : public adapts<T_functor> * * @ingroup retype */ -template <typename T_functor, typename... T_type> +template<typename T_functor, typename... T_type> struct visitor<retype_functor<T_functor, T_type...>> { - template <typename T_action> - static void do_visit_each( - const T_action& action, const retype_functor<T_functor, T_type...>& target) + template<typename T_action> + static void do_visit_each(const T_action& action, + const retype_functor<T_functor, T_type...>& target) { sigc::visit_each(action, target.functor_); } @@ -123,7 +121,9 @@ struct visitor<retype_functor<T_functor, T_type...>> * * @ingroup retype */ -template <template <typename T_func, typename... T_arg> class T_functor, typename T_func, typename... T_arg> +template<template<typename T_func, typename... T_arg> class T_functor, + typename T_func, + typename... T_arg> inline decltype(auto) retype(const T_functor<T_func, T_arg...>& functor) { @@ -139,7 +139,9 @@ retype(const T_functor<T_func, T_arg...>& functor) * * @ingroup retype */ -template <template <typename T_return, typename... T_arg> class T_functor, typename T_return, typename... T_arg> +template<template<typename T_return, typename... T_arg> class T_functor, + typename T_return, + typename... T_arg> inline decltype(auto) retype(const T_functor<T_return(T_arg...)>& functor) { diff --git a/sigc++/adaptors/retype_return.h b/sigc++/adaptors/retype_return.h index 57959f9..e3911b8 100644 --- a/sigc++/adaptors/retype_return.h +++ b/sigc++/adaptors/retype_return.h @@ -33,10 +33,10 @@ namespace sigc * * @ingroup retype */ -template <typename T_return, typename T_functor> +template<typename T_return, typename T_functor> struct retype_return_functor : public adapts<T_functor> { - template <typename... T_arg> + template<typename... T_arg> inline T_return operator()(T_arg&&... a) { return T_return(std::invoke(this->functor_, std::forward<T_arg>(a)...)); @@ -48,8 +48,7 @@ struct retype_return_functor : public adapts<T_functor> * the passed functor. * @param functor Functor to invoke from operator()(). */ - explicit retype_return_functor(type_trait_take_t<T_functor> functor) - : adapts<T_functor>(functor) + explicit retype_return_functor(type_trait_take_t<T_functor> functor) : adapts<T_functor>(functor) { } }; @@ -64,10 +63,10 @@ struct retype_return_functor : public adapts<T_functor> */ /* The void specialization is needed because of explicit cast to T_return. */ -template <typename T_functor> +template<typename T_functor> struct retype_return_functor<void, T_functor> : public adapts<T_functor> { - template <typename... T_arg> + template<typename... T_arg> inline void operator()(T_arg... a) { std::invoke(this->functor_, a...); @@ -85,12 +84,12 @@ struct retype_return_functor<void, T_functor> : public adapts<T_functor> * * @ingroup retype */ -template <typename T_return, typename T_functor> +template<typename T_return, typename T_functor> struct visitor<retype_return_functor<T_return, T_functor>> { - template <typename T_action> - static void do_visit_each( - const T_action& action, const retype_return_functor<T_return, T_functor>& target) + template<typename T_action> + static void do_visit_each(const T_action& action, + const retype_return_functor<T_return, T_functor>& target) { sigc::visit_each(action, target.functor_); } @@ -106,7 +105,7 @@ struct visitor<retype_return_functor<T_return, T_functor>> * * @ingroup retype */ -template <typename T_return, typename T_functor> +template<typename T_return, typename T_functor> inline retype_return_functor<T_return, T_functor> retype_return(const T_functor& functor) { @@ -121,7 +120,7 @@ retype_return(const T_functor& functor) * * @ingroup hide */ -template <typename T_functor> +template<typename T_functor> inline retype_return_functor<void, T_functor> hide_return(const T_functor& functor) { diff --git a/sigc++/adaptors/track_obj.h b/sigc++/adaptors/track_obj.h index d894781..6f208f3 100644 --- a/sigc++/adaptors/track_obj.h +++ b/sigc++/adaptors/track_obj.h @@ -65,7 +65,7 @@ namespace sigc * * @ingroup track_obj */ -template <typename T_functor, typename... T_obj> +template<typename T_functor, typename... T_obj> class track_obj_functor : public adapts<T_functor> { public: @@ -83,7 +83,7 @@ public: * @param arg Arguments to be passed on to the functor. * @return The return value of the functor invocation. */ - template <typename... T_arg> + template<typename... T_arg> decltype(auto) operator()(T_arg&&... arg) { return std::invoke(this->functor_, std::forward<T_arg>(arg)...); @@ -108,17 +108,17 @@ public: * * @ingroup track_obj */ -template <typename T_functor, typename... T_obj> +template<typename T_functor, typename... T_obj> struct visitor<track_obj_functor<T_functor, T_obj...>> { - template <typename T_action> - static void do_visit_each( - const T_action& action, const track_obj_functor<T_functor, T_obj...>& target) + template<typename T_action> + static void do_visit_each(const T_action& action, + const track_obj_functor<T_functor, T_obj...>& target) { sigc::visit_each(action, target.functor_); // Call sigc::visit_each(action, element) on each element in the - //target.obj_ tuple: + // target.obj_ tuple: sigc::internal::tuple_for_each<internal::TupleVisitorVisitEach>(target.obj_, action); } }; @@ -133,7 +133,7 @@ struct visitor<track_obj_functor<T_functor, T_obj...>> * * @ingroup track_obj */ -template <typename T_functor, typename... T_obj> +template<typename T_functor, typename... T_obj> inline decltype(auto) track_obj(const T_functor& func, const T_obj&... obj) { diff --git a/sigc++/adaptors/tuple_visitor_visit_each.h b/sigc++/adaptors/tuple_visitor_visit_each.h index 5cccd49..60f977e 100644 --- a/sigc++/adaptors/tuple_visitor_visit_each.h +++ b/sigc++/adaptors/tuple_visitor_visit_each.h @@ -29,10 +29,10 @@ namespace internal { #ifndef DOXYGEN_SHOULD_SKIP_THIS -template <typename T_element> +template<typename T_element> struct TupleVisitorVisitEach { - template <typename T_action> + template<typename T_action> constexpr static void visit(const T_element& element, T_action&& action) { sigc::visit_each(std::forward<T_action>(action), element); diff --git a/sigc++/connection.cc b/sigc++/connection.cc index f70a9ba..0f9318d 100644 --- a/sigc++/connection.cc +++ b/sigc++/connection.cc @@ -22,19 +22,11 @@ namespace sigc { -connection::connection() noexcept : slot_(nullptr) -{ -} - -connection::connection(slot_base& slot) -: slot_(&slot) -{ -} +connection::connection() noexcept : slot_(nullptr) {} +connection::connection(slot_base& slot) : slot_(&slot) {} -connection::connection(const connection& c) : slot_(c.slot_) -{ -} +connection::connection(const connection& c) : slot_(c.slot_) {} connection& connection::operator=(const connection& src) @@ -43,9 +35,7 @@ connection::operator=(const connection& src) return *this; } -connection::~connection() -{ -} +connection::~connection() {} bool connection::empty() const noexcept @@ -95,5 +85,4 @@ connection::set_slot(const sigc::internal::weak_raw_ptr<slot_base>& sl) slot_ = sl; } - } /* namespace sigc */ diff --git a/sigc++/functors/functor_trait.h b/sigc++/functors/functor_trait.h index d50c457..61e5c68 100644 --- a/sigc++/functors/functor_trait.h +++ b/sigc++/functors/functor_trait.h @@ -54,7 +54,7 @@ namespace sigc * * @ingroup sigcfunctors */ -template <typename T_functor> +template<typename T_functor> struct functor_trait { using functor_type = T_functor; @@ -65,7 +65,7 @@ struct functor_trait // functor ptr fun: -template <typename T_return, typename... T_arg> +template<typename T_return, typename... T_arg> struct functor_trait<T_return (*)(T_arg...)> { using functor_type = pointer_functor<T_return(T_arg...)>; @@ -73,13 +73,13 @@ struct functor_trait<T_return (*)(T_arg...)> // functor mem fun: -template <typename T_return, typename T_obj, typename... T_arg> +template<typename T_return, typename T_obj, typename... T_arg> struct functor_trait<T_return (T_obj::*)(T_arg...)> { using functor_type = mem_functor<T_return (T_obj::*)(T_arg...), T_arg...>; }; -template <typename T_return, typename T_obj, typename... T_arg> +template<typename T_return, typename T_obj, typename... T_arg> struct functor_trait<T_return (T_obj::*)(T_arg...) const> { using functor_type = mem_functor<T_return (T_obj::*)(T_arg...) const, T_arg...>; diff --git a/sigc++/functors/mem_fun.h b/sigc++/functors/mem_fun.h index b4a1b68..65563a3 100644 --- a/sigc++/functors/mem_fun.h +++ b/sigc++/functors/mem_fun.h @@ -87,7 +87,7 @@ namespace sigc * @ingroup sigcfunctors */ -template <typename T_func, typename... T_arg> +template<typename T_func, typename... T_arg> class mem_functor { public: @@ -95,9 +95,8 @@ public: using function_type = T_func; - using obj_type_with_modifier = - typename std::conditional_t<internal::member_method_is_const<T_func>::value, const object_type, - object_type>; + using obj_type_with_modifier = typename std:: + conditional_t<internal::member_method_is_const<T_func>::value, const object_type, object_type>; /// Constructs an invalid functor. mem_functor() : func_ptr_(nullptr) {} @@ -121,7 +120,7 @@ protected: function_type func_ptr_; }; -template <typename T_func, typename... T_arg> +template<typename T_func, typename... T_arg> class bound_mem_functor : mem_functor<T_func, T_arg...> { using base_type = mem_functor<T_func, T_arg...>; @@ -131,21 +130,18 @@ public: using object_type = typename base_type::object_type; - using obj_type_with_modifier = - typename std::conditional_t<internal::member_method_is_const<T_func>::value, const object_type, - object_type>; + using obj_type_with_modifier = typename std:: + conditional_t<internal::member_method_is_const<T_func>::value, const object_type, object_type>; using T_limit_reference = typename std::conditional_t<internal::member_method_is_const<T_func>::value, - limit_reference<const object_type>, limit_reference<object_type>>; + limit_reference<const object_type>, + limit_reference<object_type>>; /** Constructs a bound_mem_functor object that wraps the passed method. * @param obj Reference to instance the method will operate on. * @param func Pointer to method will be invoked from operator()(). */ - bound_mem_functor(obj_type_with_modifier& obj, function_type func) - : base_type(func), obj_(obj) - { - } + bound_mem_functor(obj_type_with_modifier& obj, function_type func) : base_type(func), obj_(obj) {} /** Execute the wrapped method operating on the stored instance. * @param a Arguments to be passed on to the method. @@ -170,12 +166,12 @@ public: * * @ingroup mem_fun */ -template <typename T_func, typename... T_arg> +template<typename T_func, typename... T_arg> struct visitor<bound_mem_functor<T_func, T_arg...>> { - template <typename T_action> - static void do_visit_each( - const T_action& action, const bound_mem_functor<T_func, T_arg...>& target) + template<typename T_action> + static void do_visit_each(const T_action& action, + const bound_mem_functor<T_func, T_arg...>& target) { sigc::visit_each(action, target.obj_); } @@ -188,9 +184,8 @@ struct visitor<bound_mem_functor<T_func, T_arg...>> * * @ingroup mem_fun */ -template <typename T_return, typename T_obj, typename... T_arg> -inline decltype(auto) -mem_fun(T_return (T_obj::*func)(T_arg...)) +template<typename T_return, typename T_obj, typename... T_arg> +inline decltype(auto) mem_fun(T_return (T_obj::*func)(T_arg...)) { return mem_functor<T_return (T_obj::*)(T_arg...), T_arg...>(func); } @@ -201,7 +196,7 @@ mem_fun(T_return (T_obj::*func)(T_arg...)) * * @ingroup mem_fun */ -template <typename T_return, typename T_obj, typename... T_arg> +template<typename T_return, typename T_obj, typename... T_arg> inline decltype(auto) mem_fun(T_return (T_obj::*func)(T_arg...) const) { @@ -214,9 +209,8 @@ mem_fun(T_return (T_obj::*func)(T_arg...) const) * * @ingroup mem_fun */ -template <typename T_return, typename T_obj, typename... T_arg> -inline decltype(auto) -mem_fun(T_return (T_obj::*func)(T_arg...) volatile) +template<typename T_return, typename T_obj, typename... T_arg> +inline decltype(auto) mem_fun(T_return (T_obj::*func)(T_arg...) volatile) { return mem_functor<T_return (T_obj::*)(T_arg...) volatile, T_arg...>(func); } @@ -227,7 +221,7 @@ mem_fun(T_return (T_obj::*func)(T_arg...) volatile) * * @ingroup mem_fun */ -template <typename T_return, typename T_obj, typename... T_arg> +template<typename T_return, typename T_obj, typename... T_arg> inline decltype(auto) mem_fun(T_return (T_obj::*func)(T_arg...) const volatile) { @@ -242,7 +236,7 @@ mem_fun(T_return (T_obj::*func)(T_arg...) const volatile) * * @ingroup mem_fun */ -template <typename T_return, typename T_obj, typename T_obj2, typename... T_arg> +template<typename T_return, typename T_obj, typename T_obj2, typename... T_arg> inline decltype(auto) mem_fun(/**/ T_obj& obj, T_return (T_obj2::*func)(T_arg...)) { @@ -257,7 +251,7 @@ mem_fun(/**/ T_obj& obj, T_return (T_obj2::*func)(T_arg...)) * * @ingroup mem_fun */ -template <typename T_return, typename T_obj, typename T_obj2, typename... T_arg> +template<typename T_return, typename T_obj, typename T_obj2, typename... T_arg> inline decltype(auto) mem_fun(/*const*/ T_obj& obj, T_return (T_obj2::*func)(T_arg...) const) { @@ -272,7 +266,7 @@ mem_fun(/*const*/ T_obj& obj, T_return (T_obj2::*func)(T_arg...) const) * * @ingroup mem_fun */ -template <typename T_return, typename T_obj, typename T_obj2, typename... T_arg> +template<typename T_return, typename T_obj, typename T_obj2, typename... T_arg> inline decltype(auto) mem_fun(/**/ T_obj& obj, T_return (T_obj2::*func)(T_arg...) volatile) { @@ -287,7 +281,7 @@ mem_fun(/**/ T_obj& obj, T_return (T_obj2::*func)(T_arg...) volatile) * * @ingroup mem_fun */ -template <typename T_return, typename T_obj, typename T_obj2, typename... T_arg> +template<typename T_return, typename T_obj, typename T_obj2, typename... T_arg> inline decltype(auto) mem_fun(/*const*/ T_obj& obj, T_return (T_obj2::*func)(T_arg...) const volatile) { diff --git a/sigc++/functors/ptr_fun.h b/sigc++/functors/ptr_fun.h index c680a2e..288ac87 100644 --- a/sigc++/functors/ptr_fun.h +++ b/sigc++/functors/ptr_fun.h @@ -68,10 +68,10 @@ namespace sigc * * @ingroup ptr_fun */ -template <typename T_return, typename... T_args> +template<typename T_return, typename... T_args> class pointer_functor; -template <typename T_return, typename... T_args> +template<typename T_return, typename... T_args> class pointer_functor<T_return(T_args...)> { using function_type = T_return (*)(T_args...); @@ -80,7 +80,6 @@ protected: function_type func_ptr_; public: - /// Constructs an invalid functor. pointer_functor() = default; @@ -93,9 +92,7 @@ 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<T_args>... a) const { - return std::invoke(func_ptr_, a...); - } + T_return operator()(type_trait_take_t<T_args>... a) const { return std::invoke(func_ptr_, a...); } }; /** Creates a functor of type sigc::pointer_functor which wraps an existing non-member function. @@ -104,7 +101,7 @@ public: * * @ingroup ptr_fun */ -template <typename T_return, typename... T_args> +template<typename T_return, typename... T_args> inline decltype(auto) ptr_fun(T_return (*func)(T_args...)) { return pointer_functor<T_return(T_args...)>(func); diff --git a/sigc++/functors/slot.h b/sigc++/functors/slot.h index 5cda9cc..971de65 100644 --- a/sigc++/functors/slot.h +++ b/sigc++/functors/slot.h @@ -47,8 +47,9 @@ namespace internal * function_pointer_cast<>() (perhaps glibmm), can be ambiguous due to ADL * (argument-dependent lookup). */ -template <typename T_out, typename T_in> -inline T_out function_pointer_cast(T_in in) +template<typename T_out, typename T_in> +inline T_out +function_pointer_cast(T_in in) { // The double reinterpret_cast suppresses a warning from gcc8 with the // -Wcast-function-type option. @@ -62,15 +63,15 @@ inline T_out function_pointer_cast(T_in in) * notification callback. Consequently the slot_rep object will be * notified when some referred object is destroyed or overwritten. */ -template <typename T_functor> +template<typename T_functor> struct typed_slot_rep : public slot_rep { private: /* Use an adaptor type so that arguments can be passed as const references * through explicit template instantiation from slot_call#::call_it() */ using adaptor_type = typename adaptor_trait<T_functor>::adaptor_type; -public: +public: /** The functor contained by this slot_rep object. */ std::unique_ptr<adaptor_type> functor_; @@ -139,7 +140,7 @@ private: * - @e T_arg Argument types used in the definition of call_it(). * */ -template <typename T_functor, typename T_return, typename... T_arg> +template<typename T_functor, typename T_return, typename... T_arg> struct slot_call { /** Invokes a functor of type @p T_functor. @@ -191,15 +192,15 @@ struct slot_call * @ingroup slot */ #ifndef DOXYGEN_SHOULD_SKIP_THIS -template <typename T_return, typename... T_arg> +template<typename T_return, typename... T_arg> class slot; #endif // DOXYGEN_SHOULD_SKIP_THIS -template <typename T_return, typename... T_arg> +template<typename T_return, typename... T_arg> class slot<T_return(T_arg...)> : public slot_base { public: -// TODO: using arg_type_ = type_trait_take_t<T_arg>; + // TODO: using arg_type_ = type_trait_take_t<T_arg>; #ifndef DOXYGEN_SHOULD_SKIP_THIS private: @@ -215,8 +216,11 @@ public: */ inline T_return operator()(type_trait_take_t<T_arg>... a) const { - if (!empty() && !blocked()) { - return std::invoke(sigc::internal::function_pointer_cast<call_type>(slot_base::rep_->call_), slot_base::rep_, a...); + if (!empty() && !blocked()) + { + return std::invoke(sigc::internal::function_pointer_cast<call_type>(slot_base::rep_->call_), + slot_base::rep_, + a...); } return T_return(); @@ -227,7 +231,7 @@ public: /** Constructs a slot from an arbitrary functor. * @param func The desired functor the new slot should be assigned to. */ - template <typename T_functor> + template<typename T_functor> slot(const T_functor& func) : slot_base(new internal::typed_slot_rep<T_functor>(func)) { // The slot_base:: is necessary to stop the HP-UX aCC compiler from being confused. murrayc. @@ -249,8 +253,7 @@ public: * @param src The slot from which to make a copy. * @return @p this. */ - slot& operator=(const slot& src) - = default; + slot& operator=(const slot& src) = default; /** Overrides this slot, making a move from another slot. * If @p src is connected to a parent (e.g. a signal), it is copied, not moved. @@ -287,15 +290,15 @@ public: * * @ingroup slot */ -template <typename T_return, typename... T_arg> +template<typename T_return, typename... T_arg> struct visitor<slot<T_return, T_arg...>> { - static void do_visit_each( - const internal::limit_trackable_target<internal::slot_do_bind>& action, + static void do_visit_each(const internal::limit_trackable_target<internal::slot_do_bind>& action, const slot<T_return, T_arg...>& target) { if (target.rep_ && target.rep_->parent_ == nullptr) - target.rep_->set_parent(action.action_.rep_, &internal::slot_rep::notify_slot_rep_invalidated); + target.rep_->set_parent( + action.action_.rep_, &internal::slot_rep::notify_slot_rep_invalidated); } static void do_visit_each( @@ -306,7 +309,7 @@ struct visitor<slot<T_return, T_arg...>> target.rep_->unset_parent(); } - template <typename T_action> + template<typename T_action> static void do_visit_each(const T_action& action, const slot<T_return, T_arg...>& target) { action(target); diff --git a/sigc++/functors/slot_base.cc b/sigc++/functors/slot_base.cc index 106f229..b3419c9 100644 --- a/sigc++/functors/slot_base.cc +++ b/sigc++/functors/slot_base.cc @@ -92,13 +92,9 @@ slot_rep::notify_slot_rep_invalidated(notifiable* data) } // namespace internal -slot_base::slot_base() noexcept : rep_(nullptr), blocked_(false) -{ -} +slot_base::slot_base() noexcept : rep_(nullptr), blocked_(false) {} -slot_base::slot_base(rep_type* rep) noexcept : rep_(rep), blocked_(false) -{ -} +slot_base::slot_base(rep_type* rep) noexcept : rep_(rep), blocked_(false) {} slot_base::slot_base(const slot_base& src) : rep_(nullptr), blocked_(src.blocked_) { diff --git a/sigc++/functors/slot_base.h b/sigc++/functors/slot_base.h index 55cf3e6..1f7589c 100644 --- a/sigc++/functors/slot_base.h +++ b/sigc++/functors/slot_base.h @@ -66,12 +66,7 @@ public: * down dereferencing of slot list iterators. Martin. */ // TODO: Try this now? murrayc. - inline slot_rep(hook call__) noexcept - : call_(call__), - cleanup_(nullptr), - parent_(nullptr) - { - } + inline slot_rep(hook call__) noexcept : call_(call__), cleanup_(nullptr), parent_(nullptr) {} virtual ~slot_rep() {} @@ -383,4 +378,4 @@ private: } // namespace sigc -#endif //SIGC_SLOT_BASE_HPP +#endif // SIGC_SLOT_BASE_HPP diff --git a/sigc++/limit_reference.h b/sigc++/limit_reference.h index b57e4e0..f578cc3 100644 --- a/sigc++/limit_reference.h +++ b/sigc++/limit_reference.h @@ -46,7 +46,7 @@ namespace sigc * * - @e T_type The type of the reference. */ -template <typename T_type, +template<typename T_type, bool I_derives_trackable = std::is_base_of<trackable, std::decay_t<T_type>>::value> class limit_reference { @@ -88,7 +88,7 @@ private: /** limit_reference object for a class that derives from trackable. * - @e T_type The type of the reference. */ -template <typename T_type> +template<typename T_type> class limit_reference<T_type, true> { public: @@ -134,10 +134,10 @@ private: * @param action The functor to invoke. * @param target The visited instance. */ -template <typename T_type> +template<typename T_type> struct visitor<limit_reference<T_type>> { - template <typename T_action> + template<typename T_action> static void do_visit_each(const T_action& action, const limit_reference<T_type>& target) { sigc::visit_each(action, target.visit()); diff --git a/sigc++/member_method_trait.h b/sigc++/member_method_trait.h index 37c77cb..344785e 100644 --- a/sigc++/member_method_trait.h +++ b/sigc++/member_method_trait.h @@ -27,55 +27,55 @@ namespace sigc namespace internal { -template <typename> +template<typename> struct member_method_is_const; -template <typename T_obj, typename T_result, typename... T_arg> +template<typename T_obj, typename T_result, typename... T_arg> struct member_method_is_const<T_result (T_obj::*)(T_arg...)> { constexpr static bool value = false; }; -template <typename T_obj, typename T_result, typename... T_arg> +template<typename T_obj, typename T_result, typename... T_arg> struct member_method_is_const<T_result (T_obj::*)(T_arg...) volatile> { constexpr static bool value = false; }; -template <typename T_obj, typename T_result, typename... T_arg> +template<typename T_obj, typename T_result, typename... T_arg> struct member_method_is_const<T_result (T_obj::*)(T_arg...) const> { constexpr static bool value = true; }; -template <typename T_obj, typename T_result, typename... T_arg> +template<typename T_obj, typename T_result, typename... T_arg> struct member_method_is_const<T_result (T_obj::*)(T_arg...) const volatile> { constexpr static bool value = true; }; -template <typename> +template<typename> struct member_method_is_volatile; -template <typename T_obj, typename T_result, typename... T_arg> +template<typename T_obj, typename T_result, typename... T_arg> struct member_method_is_volatile<T_result (T_obj::*)(T_arg...)> { constexpr static bool value = false; }; -template <typename T_obj, typename T_result, typename... T_arg> +template<typename T_obj, typename T_result, typename... T_arg> struct member_method_is_volatile<T_result (T_obj::*)(T_arg...) const> { constexpr static bool value = false; }; -template <typename T_obj, typename T_result, typename... T_arg> +template<typename T_obj, typename T_result, typename... T_arg> struct member_method_is_volatile<T_result (T_obj::*)(T_arg...) volatile> { constexpr static bool value = true; }; -template <typename T_obj, typename T_result, typename... T_arg> +template<typename T_obj, typename T_result, typename... T_arg> struct member_method_is_volatile<T_result (T_obj::*)(T_arg...) const volatile> { constexpr static bool value = true; @@ -83,30 +83,30 @@ struct member_method_is_volatile<T_result (T_obj::*)(T_arg...) const volatile> // member method class: -template <typename T_result, typename... T_arg> +template<typename T_result, typename... T_arg> struct member_method_class { }; -template <typename T_obj, typename T_result, typename... T_arg> +template<typename T_obj, typename T_result, typename... T_arg> struct member_method_class<T_result (T_obj::*)(T_arg...)> { using type = T_obj; }; -template <typename T_obj, typename T_result, typename... T_arg> +template<typename T_obj, typename T_result, typename... T_arg> struct member_method_class<T_result (T_obj::*)(T_arg...) volatile> { using type = T_obj; }; -template <typename T_obj, typename T_result, typename... T_arg> +template<typename T_obj, typename T_result, typename... T_arg> struct member_method_class<T_result (T_obj::*)(T_arg...) const> { using type = T_obj; }; -template <typename T_obj, typename T_result, typename... T_arg> +template<typename T_obj, typename T_result, typename... T_arg> struct member_method_class<T_result (T_obj::*)(T_arg...) const volatile> { using type = T_obj; @@ -114,30 +114,30 @@ struct member_method_class<T_result (T_obj::*)(T_arg...) const volatile> // member method result: -template <typename T_result, typename... T_arg> +template<typename T_result, typename... T_arg> struct member_method_result { }; -template <typename T_obj, typename T_result, typename... T_arg> +template<typename T_obj, typename T_result, typename... T_arg> struct member_method_result<T_result (T_obj::*)(T_arg...)> { using type = T_result; }; -template <typename T_obj, typename T_result, typename... T_arg> +template<typename T_obj, typename T_result, typename... T_arg> struct member_method_result<T_result (T_obj::*)(T_arg...) volatile> { using type = T_result; }; -template <typename T_obj, typename T_result, typename... T_arg> +template<typename T_obj, typename T_result, typename... T_arg> struct member_method_result<T_result (T_obj::*)(T_arg...) const> { using type = T_result; }; -template <typename T_obj, typename T_result, typename... T_arg> +template<typename T_obj, typename T_result, typename... T_arg> struct member_method_result<T_result (T_obj::*)(T_arg...) const volatile> { using type = T_result; diff --git a/sigc++/reference_wrapper.h b/sigc++/reference_wrapper.h index 780d941..f5f12eb 100644 --- a/sigc++/reference_wrapper.h +++ b/sigc++/reference_wrapper.h @@ -24,32 +24,32 @@ namespace sigc { -template <typename T_type> +template<typename T_type> struct unwrap_reference { using type = T_type; }; -template <typename T_type> +template<typename T_type> struct unwrap_reference<std::reference_wrapper<T_type>> { using type = T_type&; }; -template <typename T_type> +template<typename T_type> struct unwrap_reference<std::reference_wrapper<const T_type>> { using type = const T_type&; }; -template <typename T_type> +template<typename T_type> T_type& unwrap(const std::reference_wrapper<T_type>& v) { return v; } -template <typename T_type> +template<typename T_type> const T_type& unwrap(const std::reference_wrapper<const T_type>& v) { diff --git a/sigc++/signal.h b/sigc++/signal.h index a819ba9..455223e 100644 --- a/sigc++/signal.h +++ b/sigc++/signal.h @@ -41,7 +41,7 @@ namespace internal * the slot. The return value is buffered, so that in an expression * like @code a = (*i) * (*i); @endcode the slot is executed only once. */ -template <typename T_emitter, typename T_result = typename T_emitter::result_type> +template<typename T_emitter, typename T_result = typename T_emitter::result_type> struct slot_iterator_buf { using size_type = std::size_t; @@ -124,7 +124,7 @@ private: /** Template specialization of slot_iterator_buf for void return signals. */ -template <typename T_emitter> +template<typename T_emitter> struct slot_iterator_buf<T_emitter, void> { using size_type = std::size_t; @@ -228,7 +228,7 @@ private: * emission when no accumulator is used, for example when the template * argument @e T_accumulator is @p void. */ -template <typename T_return, typename T_accumulator, typename... T_arg> +template<typename T_return, typename T_accumulator, typename... T_arg> struct signal_emit { using self_type = signal_emit<T_return, T_accumulator, T_arg...>; @@ -244,17 +244,15 @@ struct signal_emit * @param slot Some slot to invoke. * @return The slot's return value. */ - T_return operator()(const slot_type& slot) const - { - return std::apply(slot, a_); - } + T_return operator()(const slot_type& slot) const { return std::apply(slot, a_); } /** Executes a list of slots using an accumulator of type @e T_accumulator. * The arguments are buffered in a temporary instance of signal_emit. * @param a Arguments to be passed on to the slots. * @return The accumulated return values of the slot invocations as processed by the accumulator. */ - static decltype(auto) emit(const std::shared_ptr<internal::signal_impl>& impl, type_trait_take_t<T_arg>... a) + static decltype(auto) emit(const std::shared_ptr<internal::signal_impl>& impl, + type_trait_take_t<T_arg>... a) { using slot_iterator_buf_type = internal::slot_iterator_buf<self_type, T_return>; @@ -279,7 +277,7 @@ private: * This template specialization implements an optimized emit() * function for the case that no accumulator is used. */ -template <typename T_return, typename... T_arg> +template<typename T_return, typename... T_arg> struct signal_emit<T_return, void, T_arg...> { private: @@ -287,7 +285,6 @@ private: using call_type = typename slot_type::call_type; public: - /** Executes a list of slots. * The arguments are passed directly on to the slots. * The return value of the last slot invoked is returned. @@ -296,7 +293,8 @@ public: * @param a Arguments to be passed on to the slots. * @return The return value of the last slot invoked. */ - static decltype(auto) emit(const std::shared_ptr<internal::signal_impl>& impl, type_trait_take_t<T_arg>... a) + static decltype(auto) emit(const std::shared_ptr<internal::signal_impl>& impl, + type_trait_take_t<T_arg>... a) { if (!impl || impl->slots_.empty()) return T_return(); @@ -340,7 +338,7 @@ public: * function for the case that no accumulator is used and the * return type is @p void. */ -template <typename... T_arg> +template<typename... T_arg> struct signal_emit<void, void, T_arg...> { private: @@ -348,12 +346,12 @@ private: using call_type = typename slot_type::call_type; public: - /** Executes a list of slots using an accumulator of type @e T_accumulator. * The arguments are passed directly on to the slots. * @param a Arguments to be passed on to the slots. */ - static decltype(auto) emit(const std::shared_ptr<internal::signal_impl>& impl, type_trait_take_t<T_arg>... a) + static decltype(auto) emit(const std::shared_ptr<internal::signal_impl>& impl, + type_trait_take_t<T_arg>... a) { if (!impl || impl->slots_.empty()) return; @@ -396,7 +394,7 @@ public: * * @ingroup signal */ -template <typename T_return, typename T_accumulator, typename... T_arg> +template<typename T_return, typename T_accumulator, typename... T_arg> class signal_with_accumulator : public signal_base { public: @@ -467,8 +465,9 @@ public: */ decltype(auto) make_slot() const { - //TODO: Instead use std::result_of<> on the static emitter_type::emit() - using result_type = typename internal::member_method_result<decltype(&signal_with_accumulator::emit)>::type; + // TODO: Instead use std::result_of<> on the static emitter_type::emit() + using result_type = + typename internal::member_method_result<decltype(&signal_with_accumulator::emit)>::type; return bound_mem_functor<result_type (signal_with_accumulator::*)(type_trait_take_t<T_arg>...) const, type_trait_take_t<T_arg>...>(*this, &signal_with_accumulator::emit); @@ -530,11 +529,11 @@ public: * @ingroup signal */ #ifndef DOXYGEN_SHOULD_SKIP_THIS -template <typename T_return, typename... T_arg> +template<typename T_return, typename... T_arg> class signal; #endif // DOXYGEN_SHOULD_SKIP_THIS -template <typename T_return, typename... T_arg> +template<typename T_return, typename... T_arg> class signal<T_return(T_arg...)> : public signal_with_accumulator<T_return, void, T_arg...> { public: @@ -583,7 +582,7 @@ public: * * @ingroup signal */ - template <typename T_accumulator> + template<typename T_accumulator> class accumulated : public signal_with_accumulator<T_return, T_accumulator, T_arg...> { public: diff --git a/sigc++/signal_base.cc b/sigc++/signal_base.cc index 67f493e..c92a091 100644 --- a/sigc++/signal_base.cc +++ b/sigc++/signal_base.cc @@ -33,12 +33,12 @@ struct self_and_iter : public notifiable const signal_impl::iterator_type iter_; self_and_iter(const std::weak_ptr<signal_impl>& self, const signal_impl::iterator_type& iter) - : self_(self), iter_(iter) {} + : self_(self), iter_(iter) + { + } }; -signal_impl::signal_impl() : exec_count_(0), deferred_(false) -{ -} +signal_impl::signal_impl() : exec_count_(0), deferred_(false) {} signal_impl::~signal_impl() { @@ -204,22 +204,16 @@ signal_impl::notify_self_and_iter_of_invalidated_slot(notifiable* d) } /* namespace internal */ -signal_base::signal_base() noexcept -{ -} +signal_base::signal_base() noexcept {} -signal_base::signal_base(const signal_base& src) noexcept : impl_(src.impl()) -{ -} +signal_base::signal_base(const signal_base& src) noexcept : impl_(src.impl()) {} signal_base::signal_base(signal_base&& src) : impl_(std::move(src.impl_)) { src.impl_ = nullptr; } -signal_base::~signal_base() -{ -} +signal_base::~signal_base() {} void signal_base::clear() diff --git a/sigc++/signal_base.h b/sigc++/signal_base.h index 3bbcd4f..647ee02 100644 --- a/sigc++/signal_base.h +++ b/sigc++/signal_base.h @@ -42,8 +42,7 @@ namespace internal * or defers the execution of erase() to sweep() when the signal is being emitted. * sweep() removes all invalid slots from the list. */ -struct SIGC_API signal_impl - : public std::enable_shared_from_this<signal_impl> +struct SIGC_API signal_impl : public std::enable_shared_from_this<signal_impl> { using size_type = std::size_t; using slot_list = std::list<slot_base>; @@ -66,10 +65,7 @@ struct SIGC_API signal_impl #endif /// Increments the reference and execution counter. - inline void reference_exec() noexcept - { - ++exec_count_; - } + inline void reference_exec() noexcept { ++exec_count_; } /** Decrements the reference and execution counter. * Invokes sweep() if the execution counter reaches zero and the @@ -178,8 +174,7 @@ struct SIGC_API signal_impl_exec_holder /** Increments the execution counter of the parent sigc::signal_impl object. * @param sig The parent sigc::signal_impl object. */ - inline explicit signal_impl_exec_holder(signal_impl* sig) noexcept - : sig_(sig) + inline explicit signal_impl_exec_holder(signal_impl* sig) noexcept : sig_(sig) { sig_->reference_exec(); } diff --git a/sigc++/trackable.cc b/sigc++/trackable.cc index fdff747..c4cc822 100644 --- a/sigc++/trackable.cc +++ b/sigc++/trackable.cc @@ -22,15 +22,11 @@ namespace sigc { -trackable::trackable() noexcept : callback_list_(nullptr) -{ -} +trackable::trackable() noexcept : callback_list_(nullptr) {} /* Don't copy the notification list. The objects watching src don't need to be notified when the new object dies. */ -trackable::trackable(const trackable& /*src*/) noexcept : callback_list_(nullptr) -{ -} +trackable::trackable(const trackable& /*src*/) noexcept : callback_list_(nullptr) {} // Don't move the notification list. // The objects watching src don't need to be notified when the new object dies. @@ -38,8 +34,7 @@ trackable::trackable(const trackable& /*src*/) noexcept : callback_list_(nullptr // // If trackable's move constructor is modified, check if Glib::Object's // move constructor should be modified similarly. -trackable::trackable(trackable&& src) noexcept -: callback_list_(nullptr) +trackable::trackable(trackable&& src) noexcept : callback_list_(nullptr) { src.notify_callbacks(); } diff --git a/sigc++/tuple-utils/tuple_cdr.h b/sigc++/tuple-utils/tuple_cdr.h index 8577fef..a4c9e59 100644 --- a/sigc++/tuple-utils/tuple_cdr.h +++ b/sigc++/tuple-utils/tuple_cdr.h @@ -22,26 +22,27 @@ #include <type_traits> #include <utility> -namespace sigc::internal { +namespace sigc::internal +{ /** * Get the type of a tuple without the first item. */ -template <typename T> +template<typename T> struct tuple_type_cdr; // primary template is not defined // Partial specialization for tuples of at least one element: -template <typename H, typename... T> +template<typename H, typename... T> struct tuple_type_cdr<std::tuple<H, T...>> { using type = std::tuple<T...>; }; -namespace detail { +namespace detail +{ -template <typename T, std::size_t... I> -constexpr -decltype(auto) +template<typename T, std::size_t... I> +constexpr decltype(auto) tuple_cdr_impl(T&& t, std::index_sequence<0, I...>) { using cdr = typename tuple_type_cdr<std::decay_t<T>>::type; @@ -54,11 +55,11 @@ tuple_cdr_impl(T&& t, std::index_sequence<0, I...>) * Get the a tuple without the first item. * This is analogous to std::tuple_cat(). */ -template <typename T> -constexpr -decltype(auto) -tuple_cdr(T&& t) { - //We use std::decay_t<> because tuple_size is not defined for references. +template<typename T> +constexpr decltype(auto) +tuple_cdr(T&& t) +{ + // We use std::decay_t<> because tuple_size is not defined for references. constexpr auto size = std::tuple_size<std::decay_t<T>>::value; static_assert(size != 0, "tuple size must be non-zero"); @@ -68,4 +69,4 @@ tuple_cdr(T&& t) { } // namespace sigc::internal -#endif //SIGC_TUPLE_UTILS_TUPLE_CDR_H +#endif // SIGC_TUPLE_UTILS_TUPLE_CDR_H diff --git a/sigc++/tuple-utils/tuple_end.h b/sigc++/tuple-utils/tuple_end.h index 6c47a34..966a6c8 100644 --- a/sigc++/tuple-utils/tuple_end.h +++ b/sigc++/tuple-utils/tuple_end.h @@ -20,18 +20,22 @@ #include <sigc++/tuple-utils/tuple_cdr.h> -namespace sigc::internal { +namespace sigc::internal +{ -namespace detail { +namespace detail +{ -template <typename T, std::size_t remove_from_start> -struct tuple_type_end_impl { +template<typename T, std::size_t remove_from_start> +struct tuple_type_end_impl +{ using type = typename tuple_type_end_impl<typename tuple_type_cdr<std::decay_t<T>>::type, remove_from_start - 1>::type; }; -template <typename T> -struct tuple_type_end_impl<T, 0> { +template<typename T> +struct tuple_type_end_impl<T, 0> +{ using type = T; }; @@ -40,37 +44,44 @@ struct tuple_type_end_impl<T, 0> { /** * Get the type of a tuple with the last @a len types of the original. */ -template <typename T, std::size_t len> -struct tuple_type_end - : detail::tuple_type_end_impl<T, std::tuple_size<T>::value - len> {}; +template<typename T, std::size_t len> +struct tuple_type_end : detail::tuple_type_end_impl<T, std::tuple_size<T>::value - len> +{ +}; /** * Get the tuple with the last @a len items of the original. */ -template <std::size_t len, typename T> -constexpr -decltype(auto) // typename tuple_type_end<T, len>::type -tuple_end(T&& t) { - //We use std::decay_t<> because tuple_size is not defined for references. +template<std::size_t len, typename T> +constexpr decltype(auto) // typename tuple_type_end<T, len>::type +tuple_end(T&& t) +{ + // We use std::decay_t<> because tuple_size is not defined for references. constexpr auto size = std::tuple_size<std::decay_t<T>>::value; static_assert(len <= size, "The tuple size must be less than or equal to the length."); - if constexpr(len == 0) { + if constexpr (len == 0) + { // Prevent 'unreferenced formal parameter' warning from MSVC by 'using' t static_cast<void>(t); // Recursive calls to tuple_cdr() would result in this eventually, // but this avoids the extra work: return std::tuple<>(); - } else if constexpr(size - len == 0) { + } + else if constexpr (size - len == 0) + { return std::forward<T>(t); - } else if constexpr(size - len == 1) { + } + else if constexpr (size - len == 1) + { return tuple_cdr(std::forward<T>(t)); - } else { - return tuple_end<len>( - tuple_cdr(std::forward<T>(t))); + } + else + { + return tuple_end<len>(tuple_cdr(std::forward<T>(t))); } } } // namespace sigc::internal; -#endif //SIGC_TUPLE_UTILS_TUPLE_END_H +#endif // SIGC_TUPLE_UTILS_TUPLE_END_H diff --git a/sigc++/tuple-utils/tuple_for_each.h b/sigc++/tuple-utils/tuple_for_each.h index 5296b70..7b7fb24 100644 --- a/sigc++/tuple-utils/tuple_for_each.h +++ b/sigc++/tuple-utils/tuple_for_each.h @@ -29,10 +29,10 @@ namespace internal namespace detail { -template <template <typename> class T_visitor, std::size_t size_from_index, typename... T_extras> +template<template<typename> class T_visitor, std::size_t size_from_index, typename... T_extras> struct tuple_for_each_impl { - template <typename T> + template<typename T> constexpr static void tuple_for_each(T&& t, T_extras&&... extras) { // We use std::decay_t<> because tuple_size is not defined for references. @@ -50,10 +50,10 @@ struct tuple_for_each_impl } }; -template <template <typename> class T_visitor, typename... T_extras> +template<template<typename> class T_visitor, typename... T_extras> struct tuple_for_each_impl<T_visitor, 1, T_extras...> { - template <typename T> + template<typename T> constexpr static void tuple_for_each(T&& t, T_extras&&... extras) { // We use std::decay_t<> because tuple_size is not defined for references. @@ -69,10 +69,10 @@ struct tuple_for_each_impl<T_visitor, 1, T_extras...> } }; -template <template <typename> class T_visitor, typename... T_extras> +template<template<typename> class T_visitor, typename... T_extras> struct tuple_for_each_impl<T_visitor, 0, T_extras...> { - template <typename T> + template<typename T> constexpr static void tuple_for_each(T&& /* t */, T_extras&&... /* extras */) { // Do nothing because the tuple has no elements. @@ -92,7 +92,7 @@ struct tuple_for_each_impl<T_visitor, 0, T_extras...> * @param t The tuple whose elements should be visited. * @param extras Any extra arguments to pass to @e T_Visitor's visit() method. */ -template <template <typename> class T_visitor, typename T, typename... T_extras> +template<template<typename> class T_visitor, typename T, typename... T_extras> constexpr void tuple_for_each(T&& t, T_extras&&... extras) { @@ -103,7 +103,9 @@ tuple_for_each(T&& t, T_extras&&... extras) { detail::tuple_for_each_impl<T_visitor, size, T_extras...>::tuple_for_each( std::forward<T>(t), std::forward<T_extras>(extras)...); - } else { + } + else + { // Prevent 'unreferenced formal parameter' warning from MSVC by 'using' t static_cast<void>(t); } diff --git a/sigc++/tuple-utils/tuple_start.h b/sigc++/tuple-utils/tuple_start.h index c220a92..6c83030 100644 --- a/sigc++/tuple-utils/tuple_start.h +++ b/sigc++/tuple-utils/tuple_start.h @@ -21,15 +21,18 @@ #include <tuple> #include <utility> -namespace sigc::internal { +namespace sigc::internal +{ -namespace detail { +namespace detail +{ -template <typename T, typename Seq> +template<typename T, typename Seq> struct tuple_type_start_impl; -template <typename T, std::size_t... I> -struct tuple_type_start_impl<T, std::index_sequence<I...>> { +template<typename T, std::size_t... I> +struct tuple_type_start_impl<T, std::index_sequence<I...>> +{ using type = std::tuple<typename std::tuple_element<I, T>::type...>; }; @@ -38,21 +41,22 @@ struct tuple_type_start_impl<T, std::index_sequence<I...>> { /** * Get the type of a tuple with just the first @len items. */ -template <typename T, std::size_t len> -struct tuple_type_start - : detail::tuple_type_start_impl<T, std::make_index_sequence<len>> {}; +template<typename T, std::size_t len> +struct tuple_type_start : detail::tuple_type_start_impl<T, std::make_index_sequence<len>> +{ +}; -namespace detail { +namespace detail +{ -template <typename T, typename Seq> +template<typename T, typename Seq> struct tuple_start_impl; -template <typename T, std::size_t... I> -struct tuple_start_impl<T, std::index_sequence<I...>> { - static - constexpr - decltype(auto) - tuple_start(T&& t) { +template<typename T, std::size_t... I> +struct tuple_start_impl<T, std::index_sequence<I...>> +{ + static constexpr decltype(auto) tuple_start(T&& t) + { constexpr auto size = std::tuple_size<std::decay_t<T>>::value; constexpr auto len = sizeof...(I); static_assert(len <= size, "The tuple size must be less than or equal to the length."); @@ -67,11 +71,11 @@ struct tuple_start_impl<T, std::index_sequence<I...>> { /** * Get the tuple with the last @a len items of the original. */ -template <std::size_t len, typename T> -constexpr -decltype(auto) // typename tuple_type_end<T, len>::type -tuple_start(T&& t) { - //We use std::decay_t<> because tuple_size is not defined for references. +template<std::size_t len, typename T> +constexpr decltype(auto) // typename tuple_type_end<T, len>::type +tuple_start(T&& t) +{ + // We use std::decay_t<> because tuple_size is not defined for references. constexpr auto size = std::tuple_size<std::decay_t<T>>::value; static_assert(len <= size, "The tuple size must be less than or equal to the length."); @@ -81,4 +85,4 @@ tuple_start(T&& t) { } // namespace sigc::internal; -#endif //SIGC_TUPLE_UTILS_TUPLE_START_H +#endif // SIGC_TUPLE_UTILS_TUPLE_START_H diff --git a/sigc++/tuple-utils/tuple_transform_each.h b/sigc++/tuple-utils/tuple_transform_each.h index fa1f7a8..570e59b 100644 --- a/sigc++/tuple-utils/tuple_transform_each.h +++ b/sigc++/tuple-utils/tuple_transform_each.h @@ -23,43 +23,52 @@ #include <sigc++/tuple-utils/tuple_start.h> #include <type_traits> -namespace sigc::internal { +namespace sigc::internal +{ -namespace detail { +namespace detail +{ -template <template <typename> class T_transformer, std::size_t size_from_index> -struct tuple_transform_each_impl { +template<template<typename> class T_transformer, std::size_t size_from_index> +struct tuple_transform_each_impl +{ // TODO: Avoid the need to pass t_original all the way into the recursion? - template <typename T_current, typename T_original> - constexpr - static decltype(auto) - tuple_transform_each(T_current&& t, T_original& t_original) { - if constexpr(size_from_index == 0) { - // Prevent 'unreferenced formal parameter' warning from MSVC by 'using' - // t_original + template<typename T_current, typename T_original> + constexpr static decltype(auto) tuple_transform_each(T_current&& t, T_original& t_original) + { + if constexpr (size_from_index == 0) + { + // Prevent 'unreferenced formal parameter' warning from MSVC by 'using' + // t_original static_cast<void>(t_original); - //Do nothing because the tuple has no elements. + // Do nothing because the tuple has no elements. return std::forward<T_current>(t); - } else { //TODO: Should this compile without using else to contain the alternative code? - //We use std::decay_t<> because tuple_size is not defined for references. + } + else + { // TODO: Should this compile without using else to contain the alternative code? + // We use std::decay_t<> because tuple_size is not defined for references. constexpr auto size = std::tuple_size<std::decay_t<T_current>>::value; constexpr auto index = size - size_from_index; static_assert(index >= 0, "unexpected index."); using from_element_type = typename std::tuple_element<index, std::decay_t<T_original>>::type; - using to_element_type = typename std::invoke_result<decltype ( - &T_transformer<from_element_type>::transform), from_element_type&>::type; + using to_element_type = + typename std::invoke_result<decltype(&T_transformer<from_element_type>::transform), + from_element_type&>::type; // Tuples which are input data to std::tuple_cat() should not be declared const. // Some versions of libc++ has a bug in std::tuple_cat(): All output elements // coming from a const tuple become const. // https://github.com/libsigcplusplus/libsigcplusplus/issues/25 - auto t_element = - std::tuple<to_element_type>(T_transformer<from_element_type>::transform(std::get<index>(t_original))); + auto t_element = std::tuple<to_element_type>( + T_transformer<from_element_type>::transform(std::get<index>(t_original))); - if constexpr(size_from_index == 1) { + if constexpr (size_from_index == 1) + { auto tuple_rest = tuple_start<size - 1>(std::forward<T_current>(t)); return std::tuple_cat(tuple_rest, t_element); - } else { + } + else + { auto t_start = tuple_start<index>(std::forward<T_current>(t)); // t_end's elements will be copies of the elements in t, so this method's @@ -71,8 +80,8 @@ struct tuple_transform_each_impl { auto t_end = tuple_end<size - index - 1>(t); auto t_with_transformed_element = std::tuple_cat(t_start, t_element, t_end); - return tuple_transform_each_impl<T_transformer, - size_from_index - 1>::tuple_transform_each(t_with_transformed_element, t_original); + return tuple_transform_each_impl<T_transformer, size_from_index - 1>::tuple_transform_each( + t_with_transformed_element, t_original); } } } @@ -84,17 +93,17 @@ struct tuple_transform_each_impl { * Get a tuple with each element having the transformed value of the element * in the original tuple. */ -template <template <typename> class T_transformer, typename T> -constexpr -decltype(auto) -tuple_transform_each(T&& t) { - //We use std::decay_t<> because tuple_size is not defined for references. +template<template<typename> class T_transformer, typename T> +constexpr decltype(auto) +tuple_transform_each(T&& t) +{ + // We use std::decay_t<> because tuple_size is not defined for references. constexpr auto size = std::tuple_size<std::decay_t<T>>::value; - return detail::tuple_transform_each_impl<T_transformer, - size>::tuple_transform_each(std::forward<T>(t), t); + return detail::tuple_transform_each_impl<T_transformer, size>::tuple_transform_each( + std::forward<T>(t), t); } } // namespace sigc::internal -#endif //SIGC_TUPLE_UTILS_TUPLE_TRANSFORM_EACH_H +#endif // SIGC_TUPLE_UTILS_TUPLE_TRANSFORM_EACH_H diff --git a/sigc++/type_traits.h b/sigc++/type_traits.h index 849f75f..1af84e1 100644 --- a/sigc++/type_traits.h +++ b/sigc++/type_traits.h @@ -24,45 +24,45 @@ namespace sigc { -template <typename T_type> +template<typename T_type> struct type_trait { using pass = T_type&; using take = const T_type&; }; -template <typename T_type, int N> +template<typename T_type, int N> struct type_trait<T_type[N]> { using pass = T_type*&; using take = const T_type*&; }; -template <typename T_type> +template<typename T_type> struct type_trait<T_type&> { using pass = T_type&; using take = T_type&; }; -template <typename T_type> +template<typename T_type> struct type_trait<const T_type&> { using pass = const T_type&; using take = const T_type&; }; -template <> +template<> struct type_trait<void> { using pass = void; using take = void; }; -template <typename T> +template<typename T> using type_trait_pass_t = typename type_trait<T>::pass; -template <typename T> +template<typename T> using type_trait_take_t = typename type_trait<T>::take; } /* namespace sigc */ diff --git a/sigc++/visit_each.h b/sigc++/visit_each.h index 032068a..39ee408 100644 --- a/sigc++/visit_each.h +++ b/sigc++/visit_each.h @@ -32,23 +32,26 @@ struct trackable; namespace internal { -template <typename Base, typename Derived> +template<typename Base, typename Derived> constexpr bool is_base_of_or_same_v = std::is_base_of<std::decay_t<Base>, std::decay_t<Derived>>::value || - std::is_same<std::decay_t<Base>, std::decay_t<Derived>>::value; + std::is_same<std::decay_t<Base>, std::decay_t<Derived>>::value; /// Helper struct for visit_each_trackable(). -template <typename T_action> +template<typename T_action> struct limit_trackable_target { - template <typename T_type> + template<typename T_type> void operator()(T_type&& type) const { - //Only call action_() if T_Type derives from trackable. - if constexpr(is_base_of_or_same_v<sigc::trackable, T_type>) { - std::invoke(action_, type); - } else { - // Prevent 'unreferenced formal parameter' warning from MSVC by 'using' type + // Only call action_() if T_Type derives from trackable. + if constexpr (is_base_of_or_same_v<sigc::trackable, T_type>) + { + std::invoke(action_, type); + } + else + { + // Prevent 'unreferenced formal parameter' warning from MSVC by 'using' type static_cast<void>(type); } } @@ -110,10 +113,10 @@ struct limit_trackable_target * * @ingroup sigcfunctors */ -template <typename T_functor> +template<typename T_functor> struct visitor { - template <typename T_action> + template<typename T_action> static void do_visit_each(const T_action& action, const T_functor& functor) { action(functor); @@ -124,7 +127,7 @@ struct visitor * * @ingroup sigcfunctors */ -template <typename T_action, typename T_functor> +template<typename T_action, typename T_functor> void visit_each(const T_action& action, const T_functor& functor) { @@ -146,7 +149,7 @@ visit_each(const T_action& action, const T_functor& functor) * * @ingroup sigcfunctors */ -template <typename T_action, typename T_functor> +template<typename T_action, typename T_functor> void visit_each_trackable(const T_action& action, const T_functor& functor) { diff --git a/sigc++/weak_raw_ptr.h b/sigc++/weak_raw_ptr.h index 816981c..c065242 100644 --- a/sigc++/weak_raw_ptr.h +++ b/sigc++/weak_raw_ptr.h @@ -31,24 +31,20 @@ namespace internal /** T must derive from sigc::trackable. */ -template <typename T> +template<typename T> struct weak_raw_ptr : public sigc::notifiable { - inline weak_raw_ptr() - : p_(nullptr) - {} + inline weak_raw_ptr() : p_(nullptr) {} - inline weak_raw_ptr(T* p) noexcept - : p_(p) + inline weak_raw_ptr(T* p) noexcept : p_(p) { - if(!p) + if (!p) return; p->add_destroy_notify_callback(this, ¬ify_object_invalidated); } - inline weak_raw_ptr(const weak_raw_ptr& src) noexcept - : p_(src.p_) + inline weak_raw_ptr(const weak_raw_ptr& src) noexcept : p_(src.p_) { if (p_) p_->add_destroy_notify_callback(this, ¬ify_object_invalidated); @@ -56,38 +52,34 @@ struct weak_raw_ptr : public sigc::notifiable inline weak_raw_ptr& operator=(const weak_raw_ptr& src) noexcept { - if(p_) { + if (p_) + { p_->remove_destroy_notify_callback(this); } p_ = src.p_; - + if (p_) p_->add_destroy_notify_callback(this, ¬ify_object_invalidated); return *this; } - //TODO: + // TODO: weak_raw_ptr(weak_raw_ptr&& src) = delete; weak_raw_ptr& operator=(weak_raw_ptr&& src) = delete; inline ~weak_raw_ptr() noexcept { - if (p_) { + if (p_) + { p_->remove_destroy_notify_callback(this); } } - inline explicit operator bool() const noexcept - { - return p_ != nullptr; - } + inline explicit operator bool() const noexcept { return p_ != nullptr; } - inline T* operator->() const noexcept - { - return p_; - } + inline T* operator->() const noexcept { return p_; } private: /** Callback that is executed when the objet is destroyed. @@ -96,7 +88,7 @@ private: static void notify_object_invalidated(notifiable* data) { auto self = static_cast<weak_raw_ptr*>(data); - if(!self) + if (!self) return; self->p_ = nullptr; |