diff options
| author | Murray Cumming <murrayc@murrayc.com> | 2016-01-14 19:32:49 +0100 |
|---|---|---|
| committer | Murray Cumming <murrayc@murrayc.com> | 2016-03-01 22:26:47 +0100 |
| commit | 5552b9c9209141bd0564f2e89bb5f18aaa1466b5 (patch) | |
| tree | aeea42798bc99f26e802f815e51c14cd19ff5126 | |
| parent | 3dac07a124a999f9c4555187b5042d7550fd26bb (diff) | |
| download | sigc++-5552b9c9209141bd0564f2e89bb5f18aaa1466b5.tar.gz | |
Replace some uses of result_type with decltype(auto).
| -rw-r--r-- | sigc++/adaptors/adaptor_trait.h | 11 | ||||
| -rw-r--r-- | sigc++/adaptors/compose.h | 22 | ||||
| -rw-r--r-- | sigc++/adaptors/exception_catch.h | 20 | ||||
| -rw-r--r-- | sigc++/adaptors/macros/bind.h.m4 | 4 | ||||
| -rw-r--r-- | sigc++/adaptors/macros/retype.h.m4 | 8 | ||||
| -rw-r--r-- | sigc++/adaptors/macros/track_obj.h.m4 | 2 | ||||
| -rw-r--r-- | sigc++/signal.h | 22 |
7 files changed, 35 insertions, 54 deletions
diff --git a/sigc++/adaptors/adaptor_trait.h b/sigc++/adaptors/adaptor_trait.h index a9b2a72..9c20d0c 100644 --- a/sigc++/adaptors/adaptor_trait.h +++ b/sigc++/adaptors/adaptor_trait.h @@ -82,9 +82,9 @@ struct adaptor_functor : public adaptor_base /** Invokes the wrapped functor passing on the arguments. * @return The return value of the functor invocation. */ - result_type - operator()() const; - + decltype(auto) + operator()() const + { return functor_(); } /** Invokes the wrapped functor passing on the arguments. * @param _A_arg... Arguments to be passed on to the functor. @@ -119,11 +119,6 @@ struct adaptor_functor : public adaptor_base mutable T_functor functor_; }; -template <class T_functor> -typename adaptor_functor<T_functor>::result_type -adaptor_functor<T_functor>::operator()() const - { return functor_(); } - #ifndef DOXYGEN_SHOULD_SKIP_THIS //template specialization of visitor<>::do_visit_each<>(action, functor): /** Performs a functor on each of the targets of a functor. diff --git a/sigc++/adaptors/compose.h b/sigc++/adaptors/compose.h index 8d3a5ad..e57f009 100644 --- a/sigc++/adaptors/compose.h +++ b/sigc++/adaptors/compose.h @@ -46,8 +46,10 @@ struct compose1_functor : public adapts<T_setter> typedef T_getter getter_type; typedef typename adaptor_type::result_type result_type; - result_type - operator()(); + decltype(auto) + operator()() + { return this->functor_(get_()); } + template <class... T_arg> decltype(auto) @@ -66,11 +68,6 @@ struct compose1_functor : public adapts<T_setter> getter_type get_; // public, so that visit_each() can access it }; -template <class T_setter, class T_getter> -typename compose1_functor<T_setter, T_getter>::result_type -compose1_functor<T_setter, T_getter>::operator()() - { return this->functor_(get_()); } - /** Adaptor that combines three functors. * Use the convenience function sigc::compose() to create an instance of sigc::compose2_functor. * @@ -90,8 +87,10 @@ struct compose2_functor : public adapts<T_setter> typedef T_getter2 getter2_type; typedef typename adaptor_type::result_type result_type; - result_type - operator()(); + decltype(auto) + operator()() + { return this->functor_(get1_(), get2_()); } + template <class... T_arg> decltype(auto) @@ -114,11 +113,6 @@ struct compose2_functor : public adapts<T_setter> getter2_type get2_; // public, so that visit_each() can access it }; -template <class T_setter, class T_getter1, class T_getter2> -typename compose2_functor<T_setter, T_getter1, T_getter2>::result_type -compose2_functor<T_setter, T_getter1, T_getter2>::operator()() - { return this->functor_(get1_(), get2_()); } - #ifndef DOXYGEN_SHOULD_SKIP_THIS //template specialization of visitor<>::do_visit_each<>(action, functor): /** Performs a functor on each of the targets of a functor. diff --git a/sigc++/adaptors/exception_catch.h b/sigc++/adaptors/exception_catch.h index 0eb6da6..80ef94b 100644 --- a/sigc++/adaptors/exception_catch.h +++ b/sigc++/adaptors/exception_catch.h @@ -60,8 +60,14 @@ struct exception_catch_functor : public adapts<T_functor> typedef typename adapts<T_functor>::adaptor_type adaptor_type; typedef T_return result_type; - result_type - operator()(); + decltype(auto) + operator()() + { + try + { return this->functor_(); } + catch (...) + { return catcher_(); } + } template <class... T_arg> @@ -86,16 +92,6 @@ struct exception_catch_functor : public adapts<T_functor> T_catcher catcher_; }; -template <class T_functor, class T_catcher, class T_return> -typename exception_catch_functor<T_functor, T_catcher, T_return>::result_type -exception_catch_functor<T_functor, T_catcher, T_return>::operator()() - { - try - { return this->functor_(); } - catch (...) - { return catcher_(); } - } - // void specialization template <class T_functor, class T_catcher> struct exception_catch_functor<T_functor, T_catcher, void> : public adapts<T_functor> diff --git a/sigc++/adaptors/macros/bind.h.m4 b/sigc++/adaptors/macros/bind.h.m4 index 682b241..be37954 100644 --- a/sigc++/adaptors/macros/bind.h.m4 +++ b/sigc++/adaptors/macros/bind.h.m4 @@ -69,7 +69,7 @@ struct bind_functor<$1, T_functor, T_bound, LIST(LOOP(nil, CALL_SIZE - 1))> : pu /** Invokes the wrapped functor passing on the bound argument only. * @return The return value of the functor invocation. */ - result_type + decltype(auto) operator()() { //Note: The AIX compiler sometimes gives linker errors if we do not define this in the class. @@ -108,7 +108,7 @@ struct bind_functor<LIST(-1, T_functor, LIST(LOOP(T_type%1, $1), LOOP(nil, CALL_ /** Invokes the wrapped functor passing on the bound argument only. * @return The return value of the functor invocation. */ - result_type + decltype(auto) operator()() { //Note: The AIX compiler sometimes gives linker errors if we do not define this in the class. diff --git a/sigc++/adaptors/macros/retype.h.m4 b/sigc++/adaptors/macros/retype.h.m4 index e2b84a5..96f359b 100644 --- a/sigc++/adaptors/macros/retype.h.m4 +++ b/sigc++/adaptors/macros/retype.h.m4 @@ -20,7 +20,8 @@ include(template.macros.m4) define([RETYPE_OPERATOR],[dnl ifelse($1,0,[dnl - result_type operator()(); + decltype(auto) operator()() + { return this->functor_(); } ],[dnl template <LOOP(class T_arg%1, $1)> @@ -134,11 +135,6 @@ FOR(0,CALL_SIZE,[[RETYPE_OPERATOR(%1)]])dnl {} }; -template <LIST(class T_functor, LOOP(class T_type%1, CALL_SIZE))> -typename retype_functor<LIST(T_functor, LOOP(T_type%1, CALL_SIZE))>::result_type -retype_functor<LIST(T_functor, LOOP(T_type%1, CALL_SIZE))>::operator()() - { return this->functor_(); } - #ifndef DOXYGEN_SHOULD_SKIP_THIS //template specialization of visitor<>::do_visit_each<>(action, functor): /** Performs a functor on each of the targets of a functor. diff --git a/sigc++/adaptors/macros/track_obj.h.m4 b/sigc++/adaptors/macros/track_obj.h.m4 index 971b701..b957eae 100644 --- a/sigc++/adaptors/macros/track_obj.h.m4 +++ b/sigc++/adaptors/macros/track_obj.h.m4 @@ -167,7 +167,7 @@ public: /** Invokes the wrapped functor. * @return The return value of the functor invocation. */ - result_type operator()() + decltype(auto) operator()() { return this->functor_(); } diff --git a/sigc++/signal.h b/sigc++/signal.h index 20f6652..6f0f130 100644 --- a/sigc++/signal.h +++ b/sigc++/signal.h @@ -317,7 +317,7 @@ struct slot_iterator_buf slot_iterator_buf(const iterator_type& i, const emitter_type* c) : i_(i), c_(c), invoked_(false) {} - result_type operator*() const + decltype(auto) operator*() const { if (!i_->empty() && !i_->blocked() && !invoked_) { @@ -471,7 +471,7 @@ struct slot_reverse_iterator_buf slot_reverse_iterator_buf(const iterator_type& i, const emitter_type* c) : i_(i), c_(c), invoked_(false) {} - result_type operator*() const + decltype(auto) operator*() const { iterator_type __tmp(i_); --__tmp; @@ -642,7 +642,7 @@ struct signal_emit * @param _A_a Arguments to be passed on to the slots. * @return The accumulated return values of the slot invocations as processed by the accumulator. */ - static result_type emit(signal_impl* impl, type_trait_take_t<T_arg>... _A_a) + static decltype(auto) emit(signal_impl* impl, type_trait_take_t<T_arg>... _A_a) { T_accumulator accumulator; @@ -661,7 +661,7 @@ struct signal_emit * @param _A_a Arguments to be passed on to the slots. * @return The accumulated return values of the slot invocations as processed by the accumulator. */ - static result_type emit_reverse(signal_impl* impl, type_trait_take_t<T_arg>... _A_a) + static decltype(auto) emit_reverse(signal_impl* impl, type_trait_take_t<T_arg>... _A_a) { T_accumulator accumulator; @@ -710,7 +710,7 @@ struct signal_emit<T_return, nil, T_arg...> * @param last An iterator pointing to the last slot in the list. * @param _A_a Arguments to be passed on to the slots. * @return The return value of the last slot invoked. */ - static result_type emit(signal_impl* impl, type_trait_take_t<T_arg>... _A_a) + static decltype(auto) emit(signal_impl* impl, type_trait_take_t<T_arg>... _A_a) { if (!impl || impl->slots_.empty()) return T_return(); @@ -746,7 +746,7 @@ struct signal_emit<T_return, nil, T_arg...> * @param _A_a%1 Argument to be passed on to the slots. * @return The return value of the last slot invoked. */ - static result_type emit_reverse(signal_impl* impl, type_trait_take_t<T_arg>... _A_a) + static decltype(auto) emit_reverse(signal_impl* impl, type_trait_take_t<T_arg>... _A_a) { if (!impl || impl->slots_.empty()) return T_return(); @@ -802,7 +802,7 @@ struct signal_emit<void, nil, T_arg...> /** Executes a list of slots using an accumulator of type @e T_accumulator. * The arguments are passed directly on to the slots. * @param _A_a Arguments to be passed on to the slots. */ - static result_type emit(signal_impl* impl, type_trait_take_t<T_arg>... _A_a) + static decltype(auto) emit(signal_impl* impl, type_trait_take_t<T_arg>... _A_a) { if (!impl || impl->slots_.empty()) return; signal_exec exec(impl); @@ -820,7 +820,7 @@ struct signal_emit<void, nil, T_arg...> * @param first An iterator pointing to the first slot in the list. * @param last An iterator pointing to the last slot in the list. * @param _A_a Arguments to be passed on to the slots. */ - static result_type emit_reverse(signal_impl* impl, type_trait_take_t<T_arg>... _A_a) + static decltype(auto) emit_reverse(signal_impl* impl, type_trait_take_t<T_arg>... _A_a) { if (!impl || impl->slots_.empty()) return; signal_exec exec(impl); @@ -930,15 +930,15 @@ public: * @param _A_a Arguments to be passed on to the slots. * @return The accumulated return values of the slot invocations. */ - result_type emit(type_trait_take_t<T_arg>... _A_a) const + decltype(auto) emit(type_trait_take_t<T_arg>... _A_a) const { return emitter_type::emit(impl_, _A_a...); } /** Triggers the emission of the signal in reverse order (see emit()). */ - result_type emit_reverse(type_trait_take_t<T_arg>... _A_a) const + decltype(auto) emit_reverse(type_trait_take_t<T_arg>... _A_a) const { return emitter_type::emit_reverse(impl_, _A_a...); } /** Triggers the emission of the signal (see emit()). */ - result_type operator()(type_trait_take_t<T_arg>... _A_a) const + decltype(auto) operator()(type_trait_take_t<T_arg>... _A_a) const { return emit(_A_a...); } /** Creates a functor that calls emit() on this signal. |
