diff options
author | Murray Cumming <murrayc@murrayc.com> | 2016-01-15 09:59:25 +0100 |
---|---|---|
committer | Murray Cumming <murrayc@murrayc.com> | 2016-01-15 09:59:25 +0100 |
commit | 08f752e607889dc294ac353545072a47ff002127 (patch) | |
tree | 8921df5a168f786637ae92e983c7f490aa55e167 | |
parent | 00f3a8f73dd2bfc7441c1462e3a53bbcf3246e7d (diff) | |
download | sigc++-08f752e607889dc294ac353545072a47ff002127.tar.gz |
More use of decltype(auto) for return types.
-rw-r--r-- | sigc++/adaptors/macros/retype.h.m4 | 4 | ||||
-rw-r--r-- | sigc++/functors/macros/mem_fun.h.m4 | 15 |
2 files changed, 11 insertions, 8 deletions
diff --git a/sigc++/adaptors/macros/retype.h.m4 b/sigc++/adaptors/macros/retype.h.m4 index 9952a43..9970728 100644 --- a/sigc++/adaptors/macros/retype.h.m4 +++ b/sigc++/adaptors/macros/retype.h.m4 @@ -152,7 +152,7 @@ struct visitor<retype_functor<T_functor, T_type...> > * @ingroup retype */ template <LIST(class T_return, class... T_arg)> -inline retype_functor<slot<T_return, T_arg...>, T_arg...> +inline decltype(auto) retype(const slot<T_return, T_arg...>& _A_functor) { return retype_functor<slot<T_return, T_arg...>, T_arg...> (_A_functor); } @@ -167,7 +167,7 @@ retype(const slot<T_return, T_arg...>& _A_functor) * @ingroup retype */ template <class T_return, class... T_arg> -inline retype_functor<pointer_functor<T_return, T_arg...>, T_arg... > +inline decltype(auto) retype(const pointer_functor<T_return, T_arg...>& _A_functor) { return retype_functor<pointer_functor<T_return, T_arg...>, T_arg... > (_A_functor); } diff --git a/sigc++/functors/macros/mem_fun.h.m4 b/sigc++/functors/macros/mem_fun.h.m4 index d8bd538..33a142a 100644 --- a/sigc++/functors/macros/mem_fun.h.m4 +++ b/sigc++/functors/macros/mem_fun.h.m4 @@ -49,7 +49,8 @@ public: * @param _A_a... Argument to be passed on to the method. * @return The return value of the method invocation. */ - T_return operator()($2 T_obj* _A_obj, type_trait_take_t<T_arg>... _A_a) const + decltype(auto) + operator()($2 T_obj* _A_obj, type_trait_take_t<T_arg>... _A_a) const { return (_A_obj->*(this->func_ptr_))(_A_a...); } /** Execute the wrapped method operating on the passed instance. @@ -57,7 +58,8 @@ public: * @param _A_a... Argument to be passed on to the method. * @return The return value of the method invocation. */ - T_return operator()($2 T_obj& _A_obj, type_trait_take_t<T_arg>... _A_a) const + decltype(auto) + operator()($2 T_obj& _A_obj, type_trait_take_t<T_arg>... _A_a) const { return (_A_obj.*func_ptr_)(_A_a...); } protected: @@ -107,7 +109,8 @@ public: * @param _A_a... Argument to be passed on to the method. * @return The return value of the method invocation. */ - T_return operator()(type_trait_take_t<T_arg>... _A_a) const + decltype(auto) + operator()(type_trait_take_t<T_arg>... _A_a) const { return (obj_.invoke().*(this->func_ptr_))(_A_a...); } //protected: @@ -145,7 +148,7 @@ define([MEM_FUN],[dnl * @ingroup mem_fun */ template <class T_return, class T_obj, class... T_arg> -inline [$1]mem_functor<T_return, T_obj, T_arg...> +inline decltype(auto) mem_fun(T_return (T_obj::*_A_func)(T_arg...) $3) { return [$1]mem_functor<T_return, T_obj, T_arg...>(_A_func); } @@ -159,7 +162,7 @@ define([BOUND_MEM_FUN],[dnl * @ingroup mem_fun */ template <class T_return, class T_obj, class T_obj2, class... T_arg> -inline bound_[$1]mem_functor<T_return, T_obj, T_arg...> +inline decltype(auto) mem_fun(/*$2*/ T_obj* _A_obj, T_return (T_obj2::*_A_func)(T_arg...) $3) { return bound_[$1]mem_functor<T_return, T_obj, T_arg...>(_A_obj, _A_func); } @@ -171,7 +174,7 @@ mem_fun(/*$2*/ T_obj* _A_obj, T_return (T_obj2::*_A_func)(T_arg...) $3) * @ingroup mem_fun */ template <class T_return, class T_obj, class T_obj2, class... T_arg> -inline bound_[$1]mem_functor<T_return, T_obj, T_arg...> +inline decltype(auto) mem_fun(/*$2*/ T_obj& _A_obj, T_return (T_obj2::*_A_func)(T_arg...) $3) { return bound_[$1]mem_functor<T_return, T_obj, T_arg...>(_A_obj, _A_func); } |