diff options
author | Kjell Ahlstedt <kjell.ahlstedt@bredband.net> | 2012-09-19 09:27:54 +0200 |
---|---|---|
committer | Kjell Ahlstedt <kjell.ahlstedt@bredband.net> | 2012-09-19 09:27:54 +0200 |
commit | 2da0db61029ca85062b164d37ca6c8af142f4851 (patch) | |
tree | 31dd941765bca0e628fda44b5df20e9e50e47a7d | |
parent | 73abe4eb3f62376f7aacf2e8618b400f5ba019ee (diff) | |
download | sigc++-2da0db61029ca85062b164d37ca6c8af142f4851.tar.gz |
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.
-rw-r--r-- | ChangeLog | 11 | ||||
-rw-r--r-- | sigc++/adaptors/lambda/macros/base.h.m4 | 2 | ||||
-rw-r--r-- | sigc++/adaptors/lambda/macros/group.h.m4 | 2 | ||||
-rw-r--r-- | sigc++/functors/macros/functor_trait.h.m4 | 29 | ||||
-rw-r--r-- | tests/test_cpp11_lambda.cc | 4 |
5 files changed, 26 insertions, 22 deletions
@@ -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 |