[libsigcplusplus/variadic_mem_fun3: 11/148] adaptor_function: Make the operator() variadic.
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libsigcplusplus/variadic_mem_fun3: 11/148] adaptor_function: Make the operator() variadic.
- Date: Mon, 7 Mar 2016 09:58:43 +0000 (UTC)
commit 4da2a04557d60428f9c32ebf8b83520ad9377fa3
Author: Murray Cumming <murrayc murrayc com>
Date: Thu Jan 7 18:00:48 2016 +0100
adaptor_function: Make the operator() variadic.
Instead of generating many overloads.
sigc++/adaptors/macros/adaptor_trait.h.m4 | 49 ++++++++++++-----------------
1 files changed, 20 insertions(+), 29 deletions(-)
---
diff --git a/sigc++/adaptors/macros/adaptor_trait.h.m4 b/sigc++/adaptors/macros/adaptor_trait.h.m4
index 74ebb61..5d6a0aa 100644
--- a/sigc++/adaptors/macros/adaptor_trait.h.m4
+++ b/sigc++/adaptors/macros/adaptor_trait.h.m4
@@ -41,34 +41,6 @@ dnl via the callof<> template - a tricky way to detect the return
dnl type of a functor when the argument types are known. Martin.
])
-define([ADAPTOR_DO],[dnl
-ifelse($1,0,[dnl
-dnl typename internal::callof_safe0<T_functor>::result_type // doesn't compile if T_functor has an
overloaded operator()!
-dnl typename functor_trait<T_functor>::result_type
-dnl operator()() const
-dnl { return functor_(); }
-],[dnl
- /** Invokes the wrapped functor passing on the arguments.dnl
-FOR(1, $1,[
- * @param _A_arg%1 Argument to be passed on to the functor.])
- * @return The return value of the functor invocation.
- */
- template <LOOP([class T_arg%1], $1)>
- typename deduce_result_type<LOOP(T_arg%1, $1)>::type
- operator()(LOOP(T_arg%1 _A_arg%1, $1)) const
- { return functor_(LOOP(_A_arg%1, $1)); }
-
- #ifndef SIGC_TEMPLATE_SPECIALIZATION_OPERATOR_OVERLOAD
- 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_arg%1, $1)) const
- { //Just calling operator() tries to copy the argument:
- return functor_(LOOP(_A_arg%1, $1));
- }
- #endif
-
-])dnl
-])
divert(0)dnl
_FIREWALL([ADAPTORS_ADAPTOR_TRAIT])
@@ -149,7 +121,26 @@ struct adaptor_functor : public adaptor_base
{ return operator(); }
#endif
-FOR(0,CALL_SIZE,[[ADAPTOR_DO(%1)]])dnl
+
+ /** Invokes the wrapped functor passing on the arguments.
+ * @param _A_arg... Arguments to be passed on to the functor.
+ * @return The return value of the functor invocation.
+ */
+ template <class... T_arg>
+ typename deduce_result_type<T_arg...>::type
+ operator()(T_arg... _A_arg) const
+ { return functor_(_A_arg...); }
+
+ #ifndef SIGC_TEMPLATE_SPECIALIZATION_OPERATOR_OVERLOAD
+ template <class... T_arg>
+ typename deduce_result_type<T_arg...>::type
+ sun_forte_workaround(T_arg... _A_arg) const
+ { //Just calling operator() tries to copy the argument:
+ return functor_(_A_arg...);
+ }
+ #endif
+
+
/// Constructs an invalid functor.
adaptor_functor()
{}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]