[libsigc++2] type_trait: Define and use type_trait_pass/take_t aliases.



commit 3009c34f4f24ac8390f56f47401cf1418d254d20
Author: Murray Cumming <murrayc murrayc com>
Date:   Thu Aug 13 11:32:27 2015 +0200

    type_trait: Define and use type_trait_pass/take_t aliases.
    
    This simplifies the code a bit, by replacing use of this:
      typename type_trait<SomeType>::take
    with this:
      type_trait_take_t<SomeType>
    Bug #753580

 sigc++/adaptors/macros/retype.h.m4  |    6 +++---
 sigc++/functors/macros/mem_fun.h.m4 |    6 +++---
 sigc++/functors/macros/ptr_fun.h.m4 |    2 +-
 sigc++/macros/signal.h.m4           |   26 +++++++++++++-------------
 sigc++/macros/template.macros.m4    |    4 ++--
 sigc++/type_traits.h                |    6 ++++++
 6 files changed, 28 insertions(+), 22 deletions(-)
---
diff --git a/sigc++/adaptors/macros/retype.h.m4 b/sigc++/adaptors/macros/retype.h.m4
index e3effc1..06d23b8 100644
--- a/sigc++/adaptors/macros/retype.h.m4
+++ b/sigc++/adaptors/macros/retype.h.m4
@@ -26,7 +26,7 @@ ifelse($1,0,[dnl
   template <LOOP(class T_arg%1, $1)>
   typename deduce_result_type<LOOP(T_arg%1,$1)>::type
   operator()(LOOP(T_arg%1 _A_a%1, $1))
-    { return this->functor_.SIGC_WORKAROUND_OPERATOR_PARENTHESES<LOOP(typename type_trait<T_type%1>::take, 
$1)>
+    { return this->functor_.SIGC_WORKAROUND_OPERATOR_PARENTHESES<LOOP(type_trait_take_t<T_type%1>, $1)>
         (LOOP([[static_cast<T_type%1>(_A_a%1)]], $1));
     }
 
@@ -34,7 +34,7 @@ ifelse($1,0,[dnl
   template <LOOP(class T_arg%1, $1)>
   typename deduce_result_type<LOOP(T_arg%1,$1)>::type
   sun_forte_workaround(LOOP(T_arg%1 _A_a%1, $1))
-    { return this->functor_.SIGC_WORKAROUND_OPERATOR_PARENTHESES<LOOP(typename type_trait<T_type%1>::take, 
$1)>
+    { return this->functor_.SIGC_WORKAROUND_OPERATOR_PARENTHESES<LOOP(type_trait_take_t<T_type%1>, $1)>
         (LOOP([[static_cast<T_type%1>(_A_a%1)]], $1));
     }
   #endif
@@ -151,7 +151,7 @@ FOR(0,CALL_SIZE,[[RETYPE_OPERATOR(%1)]])dnl
   /** Constructs a retype_functor object that performs C-style casts on the parameters passed on to the 
functor.
    * @param _A_functor Functor to invoke from operator()().
    */
-  explicit retype_functor(typename type_trait<T_functor>::take _A_functor)
+  explicit retype_functor(type_trait_take_t<T_functor> _A_functor)
     : adapts<T_functor>(_A_functor)
     {}
 };
diff --git a/sigc++/functors/macros/mem_fun.h.m4 b/sigc++/functors/macros/mem_fun.h.m4
index 6aaf8e3..9cb6270 100644
--- a/sigc++/functors/macros/mem_fun.h.m4
+++ b/sigc++/functors/macros/mem_fun.h.m4
@@ -51,7 +51,7 @@ FOR(1, $1,[
    * @param _A_a%1 Argument to be passed on to the method.])
    * @return The return value of the method invocation.
    */
-  T_return operator()(LIST($3 T_obj* _A_obj, LOOP(typename type_trait<T_arg%1>::take _A_a%1, $1))) const
+  T_return operator()(LIST($3 T_obj* _A_obj, LOOP(type_trait_take_t<T_arg%1> _A_a%1, $1))) const
     { return (_A_obj->*(this->func_ptr_))(LOOP(_A_a%1, $1)); }
 
   /** Execute the wrapped method operating on the passed instance.
@@ -60,7 +60,7 @@ FOR(1, $1,[
    * @param _A_a%1 Argument to be passed on to the method.])
    * @return The return value of the method invocation.
    */
-  T_return operator()(LIST($3 T_obj& _A_obj, LOOP(typename type_trait<T_arg%1>::take _A_a%1, $1))) const
+  T_return operator()(LIST($3 T_obj& _A_obj, LOOP(type_trait_take_t<T_arg%1> _A_a%1, $1))) const
     { return (_A_obj.*func_ptr_)(LOOP(_A_a%1, $1)); }
 
 protected:
@@ -112,7 +112,7 @@ FOR(1, $1,[
    * @param _A_a%1 Argument to be passed on to the method.])
    * @return The return value of the method invocation.
    */
-  T_return operator()(LOOP(typename type_trait<T_arg%1>::take _A_a%1, $1)) const
+  T_return operator()(LOOP(type_trait_take_t<T_arg%1> _A_a%1, $1)) const
     { return (obj_.invoke().*(this->func_ptr_))(LOOP(_A_a%1, $1)); }
 
 //protected:
diff --git a/sigc++/functors/macros/ptr_fun.h.m4 b/sigc++/functors/macros/ptr_fun.h.m4
index 6bd734e..355b01c 100644
--- a/sigc++/functors/macros/ptr_fun.h.m4
+++ b/sigc++/functors/macros/ptr_fun.h.m4
@@ -51,7 +51,7 @@ FOR(1, $1,[
    * @param _A_a%1 Argument to be passed on to the function.])
    * @return The return value of the function invocation.
    */
-  T_return operator()(LOOP(typename type_trait<T_arg%1>::take _A_a%1, $1)) const 
+  T_return operator()(LOOP(type_trait_take_t<T_arg%1> _A_a%1, $1)) const 
     { return func_ptr_(LOOP(_A_a%1, $1)); }
 };
 
diff --git a/sigc++/macros/signal.h.m4 b/sigc++/macros/signal.h.m4
index e9cddd0..89875ce 100644
--- a/sigc++/macros/signal.h.m4
+++ b/sigc++/macros/signal.h.m4
@@ -41,7 +41,7 @@ ifelse($1,0,,[dnl
    * the values on to some slot.
    */
 ])dnl
-  signal_emit$1(LOOP(typename type_trait<T_arg%1>::take _A_a%1, $1)) ifelse($1,0,,[
+  signal_emit$1(LOOP(type_trait_take_t<T_arg%1> _A_a%1, $1)) ifelse($1,0,,[
     : LOOP(_A_a%1_(_A_a%1), $1)]) {}
 
 ifelse($1,0,[dnl
@@ -62,7 +62,7 @@ FOR(1, $1,[
    * @param _A_a%1 Argument 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(LIST(signal_impl* impl, LOOP(typename type_trait<T_arg%1>::take _A_a%1, $1)))
+  static result_type emit(LIST(signal_impl* impl, LOOP(type_trait_take_t<T_arg%1> _A_a%1, $1)))
     {
       T_accumulator accumulator;
 
@@ -84,7 +84,7 @@ FOR(1, $1,[
    * @param _A_a%1 Argument 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(LIST(signal_impl* impl, LOOP(typename type_trait<T_arg%1>::take _A_a%1, 
$1)))
+  static result_type emit_reverse(LIST(signal_impl* impl, LOOP(type_trait_take_t<T_arg%1> _A_a%1, $1)))
     {
       T_accumulator accumulator;
 
@@ -100,7 +100,7 @@ FOR(1, $1,[
     }
 dnl
   FOR(1, $1,[
-  typename type_trait<T_arg%1>::take _A_a%1_;])
+  type_trait_take_t<T_arg%1> _A_a%1_;])
 };
 
 /** Abstracts signal emission.
@@ -126,7 +126,7 @@ FOR(1, $1,[
    * @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(LIST(signal_impl* impl, LOOP(typename type_trait<T_arg%1>::take _A_a%1, $1)))
+  static result_type emit(LIST(signal_impl* impl, LOOP(type_trait_take_t<T_arg%1> _A_a%1, $1)))
     {
       if (!impl || impl->slots_.empty())
         return T_return();
@@ -167,7 +167,7 @@ FOR(1, $1,[
    * @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(LIST(signal_impl* impl, LOOP(typename type_trait<T_arg%1>::take _A_a%1, 
$1)))
+  static result_type emit_reverse(LIST(signal_impl* impl, LOOP(type_trait_take_t<T_arg%1> _A_a%1, $1)))
     {
       if (!impl || impl->slots_.empty())
         return T_return();
@@ -228,7 +228,7 @@ ifelse($1,0,,[
 FOR(1, $1,[
    * @param _A_a%1 Argument to be passed on to the slots.])
    */
-  static result_type emit(LIST(signal_impl* impl, LOOP(typename type_trait<T_arg%1>::take _A_a%1, $1)))
+  static result_type emit(LIST(signal_impl* impl, LOOP(type_trait_take_t<T_arg%1> _A_a%1, $1)))
     {
       if (!impl || impl->slots_.empty()) return;
       signal_exec exec(impl);
@@ -250,7 +250,7 @@ ifelse($1,0,,[
 FOR(1, $1,[
    * @param _A_a%1 Argument to be passed on to the slots.])
    */
-  static result_type emit_reverse(LIST(signal_impl* impl, LOOP(typename type_trait<T_arg%1>::take _A_a%1, 
$1)))
+  static result_type emit_reverse(LIST(signal_impl* impl, LOOP(type_trait_take_t<T_arg%1> _A_a%1, $1)))
     {
       if (!impl || impl->slots_.empty()) return;
       signal_exec exec(impl);
@@ -352,15 +352,15 @@ FOR(1, $1,[
    * @param _A_a%1 Argument to be passed on to the slots.])
    * @return The accumulated return values of the slot invocations.
    */
-  result_type emit(LOOP(typename type_trait<T_arg%1>::take _A_a%1, $1)) const
+  result_type emit(LOOP(type_trait_take_t<T_arg%1> _A_a%1, $1)) const
     { return emitter_type::emit(LIST(impl_, LOOP(_A_a%1, $1))); }
 
   /** Triggers the emission of the signal in reverse order (see emit()). */
-  result_type emit_reverse(LOOP(typename type_trait<T_arg%1>::take _A_a%1, $1)) const
+  result_type emit_reverse(LOOP(type_trait_take_t<T_arg%1> _A_a%1, $1)) const
     { return emitter_type::emit_reverse(LIST(impl_, LOOP(_A_a%1, $1))); }
 
   /** Triggers the emission of the signal (see emit()). */
-  result_type operator()(LOOP(typename type_trait<T_arg%1>::take _A_a%1, $1)) const
+  result_type operator()(LOOP(type_trait_take_t<T_arg%1> _A_a%1, $1)) const
     { return emit(LOOP(_A_a%1, $1)); }
 
   /** Creates a functor that calls emit() on this signal.
@@ -370,8 +370,8 @@ FOR(1, $1,[
    * yields the same result.
    * @return A functor that calls emit() on this signal.
    */
-  bound_const_mem_functor$1<LIST(result_type, signal$1, LOOP(typename type_trait<T_arg%1>::take, $1))> 
make_slot() const
-    { return bound_const_mem_functor$1<LIST(result_type, signal$1, LOOP(typename type_trait<T_arg%1>::take, 
$1))>(this, &signal$1::emit); }
+  bound_const_mem_functor$1<LIST(result_type, signal$1, LOOP(type_trait_take_t<T_arg%1>, $1))> make_slot() 
const
+    { return bound_const_mem_functor$1<LIST(result_type, signal$1, LOOP(type_trait_take_t<T_arg%1>, 
$1))>(this, &signal$1::emit); }
 
   /** Creates an STL-style interface for the signal's list of slots.
    * This interface supports iteration, insertion and removal of slots.
diff --git a/sigc++/macros/template.macros.m4 b/sigc++/macros/template.macros.m4
index 03b0667..58fb5ab 100644
--- a/sigc++/macros/template.macros.m4
+++ b/sigc++/macros/template.macros.m4
@@ -39,8 +39,8 @@ divert(1)dnl
 divert(0)dnl
 ])
 
-define([_R_],[typename type_trait<$1>::take])
-define([_P_],[typename type_trait<$1>::pass])
+define([_R_],[type_trait_take_t<$1>])
+define([_P_],[type_trait_pass_t<$1>])
 
 define([__DEPRECATION_GUARD__],[SIGCXX_DISABLE_DEPRECATED])dnl
 dnl Start deprecation
diff --git a/sigc++/type_traits.h b/sigc++/type_traits.h
index 597b23b..665a1d0 100644
--- a/sigc++/type_traits.h
+++ b/sigc++/type_traits.h
@@ -69,6 +69,12 @@ struct type_trait<void>
   typedef void* pointer;
 };
 
+template<typename T>
+using type_trait_pass_t = typename type_trait<T>::pass;
+
+template<typename T>
+using type_trait_take_t = typename type_trait<T>::take;
+
 } /* namespace sigc */
 
 #endif /* _SIGC_TYPE_TRAIT_H_ */


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