[libsigc++2/variadic] Remove result_type typedefs.



commit ddc250cc7bf554c6b29cdaa54e2045a166b61214
Author: Murray Cumming <murrayc murrayc com>
Date:   Fri Jan 15 10:36:17 2016 +0100

    Remove result_type typedefs.
    
    decltype(auto) seems to replace all need for this.

 sigc++/adaptors/adaptor_trait.h     |    7 ------
 sigc++/adaptors/bind_return.h       |    2 -
 sigc++/adaptors/compose.h           |    2 -
 sigc++/adaptors/exception_catch.h   |   40 +++-------------------------------
 sigc++/adaptors/hide.h              |    1 -
 sigc++/adaptors/macros/bind.h.m4    |    2 -
 sigc++/adaptors/macros/retype.h.m4  |    3 +-
 sigc++/adaptors/retype_return.h     |    4 ---
 sigc++/adaptors/track_obj.h         |    1 -
 sigc++/functors/functor_trait.h     |   11 +--------
 sigc++/functors/macros/mem_fun.h.m4 |    1 -
 sigc++/functors/ptr_fun.h           |    1 -
 sigc++/functors/slot.h              |    1 -
 sigc++/signal.h                     |    8 +-----
 tests/test_visit_each.cc            |    4 +--
 15 files changed, 9 insertions(+), 79 deletions(-)
---
diff --git a/sigc++/adaptors/adaptor_trait.h b/sigc++/adaptors/adaptor_trait.h
index 9c20d0c..d1a23ff 100644
--- a/sigc++/adaptors/adaptor_trait.h
+++ b/sigc++/adaptors/adaptor_trait.h
@@ -77,8 +77,6 @@ template <class T_functor> struct adapts;
 template <class T_functor>
 struct adaptor_functor : public adaptor_base
 {
-  typedef typename functor_trait<T_functor>::result_type result_type;
-
   /** Invokes the wrapped functor passing on the arguments.
    * @return The return value of the functor invocation.
    */
@@ -161,7 +159,6 @@ template <class T_functor, bool I_isadaptor = std::is_base_of<adaptor_base, T_fu
 template <class T_functor>
 struct adaptor_trait<T_functor, true>
 {
-  typedef typename T_functor::result_type result_type;
   typedef T_functor functor_type;
   typedef T_functor adaptor_type;
 };
@@ -175,7 +172,6 @@ struct adaptor_trait<T_functor, true>
 template <class T_functor>
 struct adaptor_trait<T_functor, false>
 {
-  typedef typename functor_trait<T_functor>::result_type result_type;
   typedef typename functor_trait<T_functor>::functor_type functor_type;
   typedef adaptor_functor<functor_type> adaptor_type;
 };
@@ -197,9 +193,7 @@ struct adaptor_trait<T_functor, false>
  * template <class T_functor>
  * struct my_adaptor : public sigc::adapts<T_functor>
  * {
- *   typedef typename sigc::functor_trait<T_functor>::result_type result_type;
  *   //
- *   result_type
  *   operator()() const;
  *   //
  *   template <class T_arg1>
@@ -246,7 +240,6 @@ struct adaptor_trait<T_functor, false>
 template <class T_functor>
 struct adapts : public adaptor_base
 {
-  typedef typename adaptor_trait<T_functor>::result_type  result_type;
   typedef typename adaptor_trait<T_functor>::adaptor_type adaptor_type;
 
   /** Constructs an adaptor that wraps the passed functor.
diff --git a/sigc++/adaptors/bind_return.h b/sigc++/adaptors/bind_return.h
index e6b129e..9fd0bee 100644
--- a/sigc++/adaptors/bind_return.h
+++ b/sigc++/adaptors/bind_return.h
@@ -17,8 +17,6 @@ namespace sigc {
 template <class T_return, class T_functor>
 struct bind_return_functor : public adapts<T_functor>
 {
-  typedef typename unwrap_reference<T_return>::type result_type;
-
   /** Invokes the wrapped functor dropping its return value.
    * @return The fixed return value.
    */
diff --git a/sigc++/adaptors/compose.h b/sigc++/adaptors/compose.h
index e57f009..f1ddf7e 100644
--- a/sigc++/adaptors/compose.h
+++ b/sigc++/adaptors/compose.h
@@ -44,7 +44,6 @@ struct compose1_functor : public adapts<T_setter>
   typedef typename adapts<T_setter>::adaptor_type adaptor_type;
   typedef T_setter setter_type;
   typedef T_getter getter_type;
-  typedef typename adaptor_type::result_type  result_type;
 
   decltype(auto)
   operator()()
@@ -85,7 +84,6 @@ struct compose2_functor : public adapts<T_setter>
   typedef T_setter setter_type;
   typedef T_getter1 getter1_type;
   typedef T_getter2 getter2_type;
-  typedef typename adaptor_type::result_type  result_type;
 
   decltype(auto)
   operator()()
diff --git a/sigc++/adaptors/exception_catch.h b/sigc++/adaptors/exception_catch.h
index 1ea7c3b..e8bf807 100644
--- a/sigc++/adaptors/exception_catch.h
+++ b/sigc++/adaptors/exception_catch.h
@@ -54,11 +54,10 @@ namespace sigc {
  * @ingroup adaptors
  */
 
-template <class T_functor, class T_catcher, class T_return = typename adapts<T_functor>::result_type>
+template <class T_functor, class T_catcher>
 struct exception_catch_functor : public adapts<T_functor>
 {
   typedef typename adapts<T_functor>::adaptor_type adaptor_type;
-  typedef T_return result_type;
 
   decltype(auto)
   operator()()
@@ -92,45 +91,14 @@ struct exception_catch_functor : public adapts<T_functor>
   T_catcher catcher_;
 };
 
-// void specialization
-template <class T_functor, class T_catcher>
-struct exception_catch_functor<T_functor, T_catcher, void> : public adapts<T_functor>
-{
-  typedef void result_type;
-  typedef typename adapts<T_functor>::adaptor_type adaptor_type;
-
-  template <class... T_arg>
-  decltype(auto)
-  operator()(T_arg... _A_a)
-    {
-      try
-        {
-          return this->functor_.SIGC_WORKAROUND_OPERATOR_PARENTHESES<type_trait_pass_t<T_arg>...>
-            (_A_a...);
-        }
-      catch (...)
-        { return catcher_(); }
-    }
-
-
-  exception_catch_functor() {}
-  exception_catch_functor(const T_functor& _A_func,
-                          const T_catcher& _A_catcher)
-    : adapts<T_functor>(_A_func), catcher_(_A_catcher)
-    {}
-  ~exception_catch_functor() {}
-
-    T_catcher catcher_;
-};
-
 #ifndef DOXYGEN_SHOULD_SKIP_THIS
 //template specialization of visitor<>::do_visit_each<>(action, functor):
-template <class T_functor, class T_catcher, class T_return>
-struct visitor<exception_catch_functor<T_functor, T_catcher, T_return> >
+template <class T_functor, class T_catcher>
+struct visitor<exception_catch_functor<T_functor, T_catcher> >
 {
   template <typename T_action>
   static void do_visit_each(const T_action& _A_action,
-                            const exception_catch_functor<T_functor, T_catcher, T_return>& _A_target)
+                            const exception_catch_functor<T_functor, T_catcher>& _A_target)
   {
     sigc::visit_each(_A_action, _A_target.functor_);
     sigc::visit_each(_A_action, _A_target.catcher_);
diff --git a/sigc++/adaptors/hide.h b/sigc++/adaptors/hide.h
index afed14c..88d637c 100644
--- a/sigc++/adaptors/hide.h
+++ b/sigc++/adaptors/hide.h
@@ -69,7 +69,6 @@ template <int I_location, class T_functor>
 struct hide_functor : public adapts<T_functor>
 {
   typedef typename adapts<T_functor>::adaptor_type adaptor_type;
-  typedef typename adaptor_type::result_type  result_type;
 
   /** Invokes the wrapped functor, ignoring the argument at index @e I_location (0-indexed).
    * @param _A_a Arguments to be passed on to the functor, apart from the ignored argument.
diff --git a/sigc++/adaptors/macros/bind.h.m4 b/sigc++/adaptors/macros/bind.h.m4
index 80b5f90..e091fe5 100644
--- a/sigc++/adaptors/macros/bind.h.m4
+++ b/sigc++/adaptors/macros/bind.h.m4
@@ -66,7 +66,6 @@ template <class T_functor, class T_bound>
 struct bind_functor<$1, T_functor, T_bound, LIST(LOOP(nil, CALL_SIZE - 1))> : public adapts<T_functor>
 {
   typedef typename adapts<T_functor>::adaptor_type adaptor_type;
-  typedef typename adaptor_type::result_type  result_type;
 
   /** Invokes the wrapped functor passing on the bound argument only.
    * @return The return value of the functor invocation.
@@ -106,7 +105,6 @@ template <LIST(class T_functor, LOOP(class T_type%1, $1))>
 struct bind_functor<LIST(-1, T_functor, LIST(LOOP(T_type%1, $1), LOOP(nil, CALL_SIZE - $1)))> : public 
adapts<T_functor>
 {
   typedef typename adapts<T_functor>::adaptor_type adaptor_type;
-  typedef typename adaptor_type::result_type  result_type;
 
   /** Invokes the wrapped functor passing on the bound argument only.
    * @return The return value of the functor invocation.
diff --git a/sigc++/adaptors/macros/retype.h.m4 b/sigc++/adaptors/macros/retype.h.m4
index 9970728..3157bd2 100644
--- a/sigc++/adaptors/macros/retype.h.m4
+++ b/sigc++/adaptors/macros/retype.h.m4
@@ -106,9 +106,8 @@ struct retype_functor
   : public adapts<T_functor>
 {
   typedef typename adapts<T_functor>::adaptor_type adaptor_type;
-  typedef typename adapts<T_functor>::result_type result_type;
 
- template <class... T_arg>
+  template <class... T_arg>
   decltype(auto)
   operator()(T_arg... _A_a)
     { return this->functor_.SIGC_WORKAROUND_OPERATOR_PARENTHESES<type_trait_take_t<T_type>...>
diff --git a/sigc++/adaptors/retype_return.h b/sigc++/adaptors/retype_return.h
index 56c0ac5..3a4c224 100644
--- a/sigc++/adaptors/retype_return.h
+++ b/sigc++/adaptors/retype_return.h
@@ -16,8 +16,6 @@ namespace sigc {
 template <class T_return, class T_functor>
 struct retype_return_functor : public adapts<T_functor>
 {
-  typedef T_return result_type;
-
   T_return operator()();
 
 
@@ -53,8 +51,6 @@ T_return retype_return_functor<T_return, T_functor>::operator()()
 template <class T_functor>
 struct retype_return_functor<void, T_functor> : public adapts<T_functor>
 {
-  typedef void result_type;
-
   void operator()();
 
 
diff --git a/sigc++/adaptors/track_obj.h b/sigc++/adaptors/track_obj.h
index e454f9e..39ee2aa 100644
--- a/sigc++/adaptors/track_obj.h
+++ b/sigc++/adaptors/track_obj.h
@@ -51,7 +51,6 @@ class track_obj_functor : public adapts<T_functor>
 {
 public:
   typedef typename adapts<T_functor>::adaptor_type adaptor_type;
-  typedef typename adaptor_type::result_type result_type;
 
   /** Constructs a track_obj_functor object that wraps the passed functor and
    * stores a reference to the passed trackable objects.
diff --git a/sigc++/functors/functor_trait.h b/sigc++/functors/functor_trait.h
index 176a330..4487b50 100644
--- a/sigc++/functors/functor_trait.h
+++ b/sigc++/functors/functor_trait.h
@@ -130,7 +130,6 @@ template <class T_functor,
           bool I_can_use_decltype = can_deduce_result_type_with_decltype<T_functor>::value>
 struct functor_trait
 {
-  typedef void result_type;
   typedef T_functor functor_type;
 };
 
@@ -138,14 +137,12 @@ struct functor_trait
 template <class T_functor, bool I_can_use_decltype>
 struct functor_trait<T_functor, true, I_can_use_decltype>
 {
-  typedef typename T_functor::result_type result_type;
   typedef T_functor functor_type;
 };
 
 template <typename T_functor>
 struct functor_trait<T_functor, false, true>
 {
-  typedef typename functor_trait<decltype(&T_functor::operator()), false, false>::result_type result_type;
   typedef T_functor functor_type;
 };
 #endif // DOXYGEN_SHOULD_SKIP_THIS
@@ -164,7 +161,6 @@ struct functor_trait<T_functor, false, true>
 template <class T_functor>                             \
 struct functor_trait<T_functor, false, false>          \
 {                                                      \
-  typedef typename T_functor::result_type result_type; \
   typedef T_functor functor_type;                      \
 };
 
@@ -187,13 +183,11 @@ struct functor_trait<T_functor, false, false>          \
 template <>                                    \
 struct functor_trait<T_functor, false, false>  \
 {                                              \
-  typedef T_return result_type;                \
   typedef T_functor functor_type;              \
 };                                             \
 template <>                                    \
 struct functor_trait<T_functor, false, true>   \
 {                                              \
-  typedef T_return result_type;                \
   typedef T_functor functor_type;              \
 };
 
@@ -222,7 +216,7 @@ struct functor_trait<T_functor, false, true>   \
 #endif // SIGCXX_DISABLE_DEPRECATED
 
 #ifndef DOXYGEN_SHOULD_SKIP_THIS
-// detect the return type and the functor version of non-functor types.
+// detect the the functor version of non-functor types.
 
 template <class T_return, class... T_args>
 class pointer_functor;
@@ -233,7 +227,6 @@ class pointer_functor;
 template <class T_return, class... T_arg>
 struct functor_trait<T_return (*)(T_arg...), false, false>
 {
-  typedef T_return result_type;
   typedef pointer_functor<T_return, T_arg...> functor_type;
 };
 
@@ -246,14 +239,12 @@ template <class T_return, class T_obj, class... T_arg> class const_mem_functor;
 template <class T_return, class T_obj, class... T_arg>
 struct functor_trait<T_return (T_obj::*)(T_arg...), false, false>
 {
-  typedef T_return result_type;
   typedef mem_functor<T_return, T_obj, T_arg...> functor_type;
 };
 
 template <class T_return, class T_obj, class... T_arg>
 struct functor_trait<T_return (T_obj::*)(T_arg...) const, false, false>
 {
-  typedef T_return result_type;
   typedef const_mem_functor<T_return, T_obj, T_arg...> functor_type;
 };
 
diff --git a/sigc++/functors/macros/mem_fun.h.m4 b/sigc++/functors/macros/mem_fun.h.m4
index 33a142a..ca9051f 100644
--- a/sigc++/functors/macros/mem_fun.h.m4
+++ b/sigc++/functors/macros/mem_fun.h.m4
@@ -34,7 +34,6 @@ class [$1]mem_functor : public functor_base
 {
 public:
   typedef T_return (T_obj::*function_type)(T_arg...) $3;
-  typedef T_return result_type;
 
   /// Constructs an invalid functor.
   [$1]mem_functor() : func_ptr_(nullptr) {}
diff --git a/sigc++/functors/ptr_fun.h b/sigc++/functors/ptr_fun.h
index 9242f29..41eb85f 100644
--- a/sigc++/functors/ptr_fun.h
+++ b/sigc++/functors/ptr_fun.h
@@ -56,7 +56,6 @@ class pointer_functor : public functor_base
 protected: 
   function_type func_ptr_;
 public:
-  using result_type = T_return;
 
   /// Constructs an invalid functor.
   pointer_functor() {}
diff --git a/sigc++/functors/slot.h b/sigc++/functors/slot.h
index ea07944..620caf7 100644
--- a/sigc++/functors/slot.h
+++ b/sigc++/functors/slot.h
@@ -157,7 +157,6 @@ class slot
   : public slot_base
 {
 public:
-  typedef T_return result_type;
   //TODO: using arg_type_ = type_trait_take_t<T_arg>;
 
 #ifndef DOXYGEN_SHOULD_SKIP_THIS
diff --git a/sigc++/signal.h b/sigc++/signal.h
index f25122c..b88404a 100644
--- a/sigc++/signal.h
+++ b/sigc++/signal.h
@@ -306,7 +306,6 @@ struct slot_iterator_buf
   typedef T_result*                        pointer;
 
   typedef T_emitter                        emitter_type;
-  typedef T_result                         result_type;
   typedef typename T_emitter::slot_type    slot_type;
 
   typedef signal_impl::const_iterator_type iterator_type;
@@ -369,7 +368,7 @@ struct slot_iterator_buf
 private:
   iterator_type i_;
   const emitter_type* c_;
-  mutable result_type r_;
+  mutable T_result r_;
   mutable bool invoked_;
 };
 
@@ -383,7 +382,6 @@ struct slot_iterator_buf<T_emitter, void>
   typedef std::bidirectional_iterator_tag  iterator_category;
 
   typedef T_emitter                        emitter_type;
-  typedef void                             result_type;
   typedef typename T_emitter::slot_type    slot_type;
 
   typedef signal_impl::const_iterator_type iterator_type;
@@ -460,7 +458,6 @@ struct slot_reverse_iterator_buf
   typedef T_result*                        pointer;
 
   typedef T_emitter                        emitter_type;
-  typedef T_result                         result_type;
   typedef typename T_emitter::slot_type    slot_type;
 
   typedef signal_impl::const_iterator_type iterator_type;
@@ -525,7 +522,7 @@ struct slot_reverse_iterator_buf
 private:
   iterator_type i_;
   const emitter_type* c_;
-  mutable result_type r_;
+  mutable T_result r_;
   mutable bool invoked_;
 };
 
@@ -539,7 +536,6 @@ struct slot_reverse_iterator_buf<T_emitter, void>
   typedef std::bidirectional_iterator_tag  iterator_category;
 
   typedef T_emitter                        emitter_type;
-  typedef void                             result_type;
   typedef typename T_emitter::slot_type    slot_type;
 
   typedef signal_impl::const_iterator_type iterator_type;
diff --git a/tests/test_visit_each.cc b/tests/test_visit_each.cc
index 119ee10..d6076d0 100644
--- a/tests/test_visit_each.cc
+++ b/tests/test_visit_each.cc
@@ -88,9 +88,7 @@ namespace ns1
 template <class T_functor>
 struct MyAdaptor1 : public sigc::adapts<T_functor>
 {
-  typedef typename sigc::functor_trait<T_functor>::result_type result_type;
-
-  result_type
+  decltype(auto)
   operator()() const
   {
     result_stream << "MyAdaptor1()() ";


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]