[libsigc++2] Add SIGC_FUNCTORS_DEDUCE_RESULT_TYPE_WITH_DECLTYPE.



commit 2da0db61029ca85062b164d37ca6c8af142f4851
Author: Kjell Ahlstedt <kjell ahlstedt bredband net>
Date:   Wed Sep 19 09:27:54 2012 +0200

    Add SIGC_FUNCTORS_DEDUCE_RESULT_TYPE_WITH_DECLTYPE.
    
    * sigc++/adaptors/lambda/macros/base.h.m4:
    * sigc++/adaptors/lambda/macros/group.h.m4:
    * sigc++/functors/macros/functor_trait.h.m4:
    * tests/test_cpp11_lambda.cc: Replace the preprocessor macro
    SIGC_FUNCTORS_DEDUCE_RESULT_TYPE_WITH(C_keyword) with
    SIGC_FUNCTORS_DEDUCE_RESULT_TYPE_WITH_DECLTYPE. Bug #672555.

 ChangeLog                                 |   11 +++++++++++
 sigc++/adaptors/lambda/macros/base.h.m4   |    2 +-
 sigc++/adaptors/lambda/macros/group.h.m4  |    2 +-
 sigc++/functors/macros/functor_trait.h.m4 |   29 +++++++++++------------------
 tests/test_cpp11_lambda.cc                |    4 ++--
 5 files changed, 26 insertions(+), 22 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 931ab14..3a64a8e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2012-09-19  Kjell Ahlstedt  <kjell ahlstedt bredband net>
+
+	Add SIGC_FUNCTORS_DEDUCE_RESULT_TYPE_WITH_DECLTYPE.
+
+	* sigc++/adaptors/lambda/macros/base.h.m4:
+	* sigc++/adaptors/lambda/macros/group.h.m4:
+	* sigc++/functors/macros/functor_trait.h.m4:
+	* tests/test_cpp11_lambda.cc: Replace the preprocessor macro
+	SIGC_FUNCTORS_DEDUCE_RESULT_TYPE_WITH(C_keyword) with
+	SIGC_FUNCTORS_DEDUCE_RESULT_TYPE_WITH_DECLTYPE. Bug #672555.
+
 2012-09-10  Kjell Ahlstedt  <kjell ahlstedt bredband net>
 
 	Use std::size_t and std::ptrdiff_t.
diff --git a/sigc++/adaptors/lambda/macros/base.h.m4 b/sigc++/adaptors/lambda/macros/base.h.m4
index ef733ae..0223968 100644
--- a/sigc++/adaptors/lambda/macros/base.h.m4
+++ b/sigc++/adaptors/lambda/macros/base.h.m4
@@ -300,7 +300,7 @@ dnl { return lambda<typename internal::convert_array<const T_type>::type>(v); }
  * @endcode
  *
  * If your compiler supports C++11 lambda expressions, and you use the macro
- * SIGC_FUNCTORS_DEDUCE_RESULT_TYPE_WITH(), you can replace
+ * #SIGC_FUNCTORS_DEDUCE_RESULT_TYPE_WITH_DECLTYPE, you can replace
  * @code
  * readValue.connect(sigc::var(data));
  * @endcode
diff --git a/sigc++/adaptors/lambda/macros/group.h.m4 b/sigc++/adaptors/lambda/macros/group.h.m4
index 453415e..1d4663c 100644
--- a/sigc++/adaptors/lambda/macros/group.h.m4
+++ b/sigc++/adaptors/lambda/macros/group.h.m4
@@ -143,7 +143,7 @@ __FIREWALL__
  *
  * The functor sigc::group() returns can be passed into sigc::signal::connect() directly.
  * A C++11 lambda expression can be passed into sigc::signal::connect() directly,
- * if either it returns <tt>void</tt>, or you use SIGC_FUNCTORS_DEDUCE_RESULT_TYPE_WITH().
+ * if either it returns <tt>void</tt>, or you use #SIGC_FUNCTORS_DEDUCE_RESULT_TYPE_WITH_DECLTYPE.
  *
  * @par Example:
  * @code
diff --git a/sigc++/functors/macros/functor_trait.h.m4 b/sigc++/functors/macros/functor_trait.h.m4
index fd15c69..4e1afb7 100644
--- a/sigc++/functors/macros/functor_trait.h.m4
+++ b/sigc++/functors/macros/functor_trait.h.m4
@@ -88,10 +88,10 @@ struct nil;
  *   <tt>typedef T_return result_type;</tt> in the class definition.
  * - Use the macro SIGC_FUNCTOR_TRAIT(T_functor,T_return) in namespace sigc.
  *   Multi-type functors are only partly supported.
- * - Use the macro #SIGC_FUNCTORS_HAVE_RESULT_TYPE, if you want sigc++ to assume
+ * - Use the macro #SIGC_FUNCTORS_HAVE_RESULT_TYPE, if you want libsigc++ to assume
  *   that result_type is defined in all user-defined or third party functors,
  *   except those for which you specify a return type explicitly with SIGC_FUNCTOR_TRAIT().
- * - Use the macro SIGC_FUNCTORS_DEDUCE_RESULT_TYPE_WITH(C_keyword), if your
+ * - Use the macro #SIGC_FUNCTORS_DEDUCE_RESULT_TYPE_WITH_DECLTYPE, if your
  *   compiler makes it possible. Functors with overloaded operator()() are not
  *   supported.
  *
@@ -99,7 +99,7 @@ struct nil;
  * expression with any return type. Example:
  * @code
  * namespace sigc {
- *   SIGC_FUNCTORS_DEDUCE_RESULT_TYPE_WITH(decltype)
+ *   SIGC_FUNCTORS_DEDUCE_RESULT_TYPE_WITH_DECLTYPE
  * }
  * sigc::slot<bool, int> slot1 = [[]](int n)-> bool
  *                               {
@@ -147,7 +147,7 @@ struct functor_trait<T_functor,true>
  * @endcode
  *
  * You can't use both SIGC_FUNCTORS_HAVE_RESULT_TYPE and
- * SIGC_FUNCTORS_DEDUCE_RESULT_TYPE_WITH in the same compilation unit.
+ * SIGC_FUNCTORS_DEDUCE_RESULT_TYPE_WITH_DECLTYPE in the same compilation unit.
  *
  * @ingroup sigcfunctors
  */
@@ -184,32 +184,25 @@ struct functor_trait<T_functor,false>          \
 
 /** Helper macro, if you want to mix user-defined and third party functors with libsigc++.
  *
- * If you want to mix functors not derived from sigc::functor_base with libsigc++, and
- * your compiler can deduce the result type of the functor, use this macro inside
- * namespace sigc like so:
- * @code
- * namespace sigc {
- *   SIGC_FUNCTORS_DEDUCE_RESULT_TYPE_WITH(compiler_keyword)
- * }
- * @endcode
- *
- * For example, if your compiler understands the C++11 keyword <tt>decltype</tt>:
+ * If you want to mix functors not derived from sigc::functor_base with libsigc++,
+ * and your compiler can deduce the result type of the functor with the C++11
+ * keyword <tt>decltype</tt>, use this macro inside namespace sigc like so:
  * @code
  * namespace sigc {
- *   SIGC_FUNCTORS_DEDUCE_RESULT_TYPE_WITH(decltype)
+ *   SIGC_FUNCTORS_DEDUCE_RESULT_TYPE_WITH_DECLTYPE
  * }
  * @endcode
  *
  * You can't use both SIGC_FUNCTORS_HAVE_RESULT_TYPE and
- * SIGC_FUNCTORS_DEDUCE_RESULT_TYPE_WITH in the same compilation unit.
+ * SIGC_FUNCTORS_DEDUCE_RESULT_TYPE_WITH_DECLTYPE in the same compilation unit.
  *
  * @ingroup sigcfunctors
  */
-#define SIGC_FUNCTORS_DEDUCE_RESULT_TYPE_WITH(C_keyword) \
+#define SIGC_FUNCTORS_DEDUCE_RESULT_TYPE_WITH_DECLTYPE \
 template <typename T_functor>          \
 struct functor_trait<T_functor, false> \
 {                                      \
-  typedef typename functor_trait<C_keyword(&T_functor::operator()), false>::result_type result_type; \
+  typedef typename functor_trait<decltype(&T_functor::operator()), false>::result_type result_type; \
   typedef T_functor functor_type;      \
 };
 
diff --git a/tests/test_cpp11_lambda.cc b/tests/test_cpp11_lambda.cc
index 71b7dac..dac825b 100644
--- a/tests/test_cpp11_lambda.cc
+++ b/tests/test_cpp11_lambda.cc
@@ -35,7 +35,7 @@
 // lambda expression, connected to the slot.
 //
 // To test the C++11 lambda expressions with gcc 4.6.3 (and probably some later
-// versions of gcc):
+// versions of gcc; gcc 4.7.x also understands -std=c++11):
 //   make CXXFLAGS='-g -O2 -std=c++0x' test_cpp11_lambda
 //   ./test_cpp11_lambda
 //   echo $?
@@ -58,7 +58,7 @@
 #ifdef USING_CPP11_LAMBDA_EXPRESSIONS
 namespace sigc
 {
-  SIGC_FUNCTORS_DEDUCE_RESULT_TYPE_WITH(decltype)
+  SIGC_FUNCTORS_DEDUCE_RESULT_TYPE_WITH_DECLTYPE
 }
 #endif
 



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