summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Schulze <mschulze@cvs.gnome.org>2004-04-26 20:34:56 +0000
committerMartin Schulze <mschulze@src.gnome.org>2004-04-26 20:34:56 +0000
commit28ab95877cf29472295b3b587c7b3c4ba57f26d0 (patch)
tree598806b2206a174af3f58c710e08ac19af3d89f2
parent58cf5a52b941f4bef994373c8e5cd62704a8f7cc (diff)
downloadsigc++-28ab95877cf29472295b3b587c7b3c4ba57f26d0.tar.gz
Add work-arounds for bind<-1>::deduce_result_type compilation error on
2004-04-26 Martin Schulze <mschulze@cvs.gnome.org> * sigc++/adaptors/macros/bind.h.m4: Add work-arounds for bind<-1>::deduce_result_type compilation error on Apple gcc 3.3. * scripts/cxx.m4, sigc++config.h.in, configure.ac: Add configure check for the compilation error above. * sigc++/adaptors/lambda/macros/operator.h.m4: Replace _A with _Aa. _A is a reserved keyword on Apple gcc 3.3 (Spundun Bhatt). (fixes bug #10444 reported by Spundun Bhatt)
-rw-r--r--ChangeLog10
-rw-r--r--configure.ac1
-rw-r--r--scripts/cxx.m436
-rw-r--r--sigc++/adaptors/lambda/macros/operator.h.m48
-rw-r--r--sigc++/adaptors/macros/bind.h.m499
-rw-r--r--sigc++config.h.in2
6 files changed, 147 insertions, 9 deletions
diff --git a/ChangeLog b/ChangeLog
index f1694f3..4ca306e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2004-04-26 Martin Schulze <mschulze@cvs.gnome.org>
+
+ * sigc++/adaptors/macros/bind.h.m4: Add work-arounds for
+ bind<-1>::deduce_result_type compilation error on Apple gcc 3.3.
+ * scripts/cxx.m4, sigc++config.h.in, configure.ac: Add configure
+ check for the compilation error above.
+ * sigc++/adaptors/lambda/macros/operator.h.m4: Replace _A with
+ _Aa. _A is a reserved keyword on Apple gcc 3.3 (Spundun Bhatt).
+ (fixes bug #10444 reported by Spundun Bhatt)
+
2004-04-19 Martin Schulze <mschulze@cvs.gnome.org>
* sigc++/signal_base.cc: Fixed serious bug in signal_base::impl():
diff --git a/configure.ac b/configure.ac
index 333e3ee..ae1d532 100644
--- a/configure.ac
+++ b/configure.ac
@@ -69,6 +69,7 @@ AC_PROG_CXX
AC_LANG_CPLUSPLUS
SIGC_CXX_TEMPLATE_SPECIALIZATION_OPERATOR_OVERLOAD()
+SIGC_CXX_TEMPLATE_SPECIALIZATION_MULTIPLE()
if test "X$config_error" = "Xyes" ; then
AC_ERROR(
diff --git a/scripts/cxx.m4 b/scripts/cxx.m4
index 1de2135..b74457e 100644
--- a/scripts/cxx.m4
+++ b/scripts/cxx.m4
@@ -49,5 +49,41 @@ AC_TRY_COMPILE(
])
])
+AC_DEFUN([SIGC_CXX_TEMPLATE_SPECIALIZATION_MULTIPLE],[
+AC_MSG_CHECKING([if C++ compiler chooses the correct template specialization when offered different ones for different numbers unspecified arguments left.])
+AC_TRY_COMPILE(
+[
+ #include <iostream>
+ template <class T_type1, class T_type2>
+ struct Thing
+ {
+ static const int value = 0;
+ };
+ template <class T_type1>
+ struct Thing<T_type1, void>
+ {
+ static const int value = 1;
+ };
+
+ template <>
+ struct Thing<void,void>
+ {
+ static const int value = 2;
+ };
+],
+[
+ //This fails with on Apple gcc 3.3:
+ std::cout << "number of void arguments: " << Thing<int,void>::value << std::endl;
+],
+[
+ sigcm_cxx_template_specialization_multiple=yes
+ AC_DEFINE([SIGC_TEMPLATE_SPECIALIZATION_MULTIPLE],[1],[does the C++ compiler choose the correct template specialization when offered different ones for different numbers unspecified arguments left.])
+ AC_MSG_RESULT([$sigcm_cxx_template_specialization_multiple])
+],[
+ sigcm_cxx_template_specialization_multiple=no
+ AC_DEFINE([SIGC_TEMPLATE_SPECIALIZATION_MULTIPLE],[0])
+ AC_MSG_RESULT([$sigcm_cxx_template_specialization_multiple])
+])
+])
diff --git a/sigc++/adaptors/lambda/macros/operator.h.m4 b/sigc++/adaptors/lambda/macros/operator.h.m4
index e6fb3c7..078aa5d 100644
--- a/sigc++/adaptors/lambda/macros/operator.h.m4
+++ b/sigc++/adaptors/lambda/macros/operator.h.m4
@@ -145,8 +145,8 @@ struct lambda_action_unary<$1 >
{
template <class T_arg>
static typename lambda_action_unary_deduce_result_type<$1, T_arg>::type
- do_action(T_arg _A)
- { return $2[]_A; }
+ do_action(T_arg _Aa)
+ { return $2[]_Aa; }
};
divert(2)dnl
@@ -177,8 +177,8 @@ struct lambda_action_convert<$1, T_type>
{
template <class T_arg>
static typename lambda_action_convert_deduce_result_type<$1, T_type, T_arg>::type
- do_action(T_arg _A)
- { return $2<T_type>(_A); }
+ do_action(T_arg _Aa)
+ { return $2<T_type>(_Aa); }
};
divert(2)dnl
diff --git a/sigc++/adaptors/macros/bind.h.m4 b/sigc++/adaptors/macros/bind.h.m4
index 549476d..3626e9d 100644
--- a/sigc++/adaptors/macros/bind.h.m4
+++ b/sigc++/adaptors/macros/bind.h.m4
@@ -19,8 +19,8 @@ divert(-1)
include(template.macros.m4)
define([DEDUCE_RESULT_TYPE_COUNT],[dnl
- template <LOOP(class T_arg%1, eval(CALL_SIZE-$2))>
- struct deduce_result_type<LIST(LOOP(T_arg%1,eval(CALL_SIZE-$2)))>
+ template <LOOP(class T_arg%1, eval(CALL_SIZE))>
+ struct deduce_result_type_internal<LIST($2, LOOP(T_arg%1,eval(CALL_SIZE)))>
{ typedef typename adaptor_type::template deduce_result_type<LIST(LOOP(_P_(T_arg%1), eval(CALL_SIZE-$2)), LOOP(_P_(T_type%1), $1))>::type type; };
])
define([BIND_OPERATOR_LOCATION],[dnl
@@ -121,10 +121,16 @@ struct bind_functor<LIST(-1, T_functor, LOOP(T_type%1, $1))> : public adapts<T_f
{
typedef typename adapts<T_functor>::adaptor_type adaptor_type;
- template <LOOP(class T_arg%1=void, eval(CALL_SIZE))>
- struct deduce_result_type
+ template <LIST(int count, LOOP(class T_arg%1, eval(CALL_SIZE)))>
+ struct deduce_result_type_internal
{ typedef typename adaptor_type::template deduce_result_type<LIST(LOOP(_P_(T_arg%1), eval(CALL_SIZE-$1)), LOOP(_P_(T_type%1), $1))>::type type; };
FOR(eval($1+1),eval(CALL_SIZE-1),[[DEDUCE_RESULT_TYPE_COUNT($1,%1)]])dnl
+
+ template <LOOP(class T_arg%1=void, eval(CALL_SIZE))>
+ struct deduce_result_type {
+ typedef typename deduce_result_type_internal<internal::count_void<LOOP(T_arg%1, eval(CALL_SIZE))>::value,
+ LOOP(T_arg%1, eval(CALL_SIZE))>::type type;
+ };
typedef typename adaptor_type::result_type result_type;
/** Invokes the wrapped functor passing on the bound argument only.
@@ -200,6 +206,91 @@ __FIREWALL__
namespace sigc {
+namespace internal {
+
+#ifdef SIGC_TEMPLATE_SPECIALIZATION_MULTIPLE
+
+template <class T_arg1>
+struct count_void6
+ { static const int value=6; };
+template <>
+struct count_void6<void>
+ { static const int value=7; };
+
+template <class T_arg1,class T_arg2>
+struct count_void5
+ { static const int value=5; };
+template <class T_arg1>
+struct count_void5<T_arg1,void>
+ { static const int value=count_void6<T_arg1>::value; };
+
+template <class T_arg1,class T_arg2,class T_arg3>
+struct count_void4
+ { static const int value=4; };
+template <class T_arg1,class T_arg2>
+struct count_void4<T_arg1,T_arg2,void>
+ { static const int value=count_void5<T_arg1,T_arg2>::value; };
+
+template <class T_arg1,class T_arg2,class T_arg3,class T_arg4>
+struct count_void3
+ { static const int value=3; };
+template <class T_arg1,class T_arg2,class T_arg3>
+struct count_void3<T_arg1,T_arg2,T_arg3,void>
+ { static const int value=count_void4<T_arg1,T_arg2,T_arg3>::value; };
+
+template <class T_arg1,class T_arg2,class T_arg3,class T_arg4,class T_arg5>
+struct count_void2
+ { static const int value=2; };
+template <class T_arg1,class T_arg2,class T_arg3,class T_arg4>
+struct count_void2<T_arg1,T_arg2,T_arg3,T_arg4,void>
+ { static const int value=count_void3<T_arg1,T_arg2,T_arg3,T_arg4>::value; };
+
+template <class T_arg1,class T_arg2,class T_arg3,class T_arg4,class T_arg5,class T_arg6>
+struct count_void1
+ { static const int value=1; };
+template <class T_arg1,class T_arg2,class T_arg3,class T_arg4,class T_arg5>
+struct count_void1<T_arg1,T_arg2,T_arg3,T_arg4,T_arg5,void>
+ { static const int value=count_void2<T_arg1,T_arg2,T_arg3,T_arg4,T_arg5>::value; };
+
+template <class T_arg1,class T_arg2,class T_arg3,class T_arg4,class T_arg5,class T_arg6,class T_arg7>
+struct count_void
+ { static const int value=0; };
+template <class T_arg1,class T_arg2,class T_arg3,class T_arg4,class T_arg5,class T_arg6>
+struct count_void<T_arg1,T_arg2,T_arg3,T_arg4,T_arg5,T_arg6,void>
+ { static const int value=count_void1<T_arg1,T_arg2,T_arg3,T_arg4,T_arg5,T_arg6>::value; };
+
+#else
+
+template <class T_arg1,class T_arg2,class T_arg3,class T_arg4,class T_arg5,class T_arg6,class T_arg7>
+struct count_void
+ { static const int value=0; };
+template <class T_arg1,class T_arg2,class T_arg3,class T_arg4,class T_arg5,class T_arg6>
+struct count_void<T_arg1,T_arg2,T_arg3,T_arg4,T_arg5,T_arg6,void>
+ { static const int value=1; };
+template <class T_arg1,class T_arg2,class T_arg3,class T_arg4,class T_arg5>
+struct count_void<T_arg1,T_arg2,T_arg3,T_arg4,T_arg5,void,void>
+ { static const int value=2; };
+template <class T_arg1,class T_arg2,class T_arg3,class T_arg4>
+struct count_void<T_arg1,T_arg2,T_arg3,T_arg4,void,void,void>
+ { static const int value=3; };
+template <class T_arg1,class T_arg2,class T_arg3>
+struct count_void<T_arg1,T_arg2,T_arg3,void,void,void,void>
+ { static const int value=4; };
+template <class T_arg1,class T_arg2>
+struct count_void<T_arg1,T_arg2,void,void,void,void,void>
+ { static const int value=5; };
+template <class T_arg1>
+struct count_void<T_arg1,void,void,void,void,void,void>
+ { static const int value=6; };
+template <>
+struct count_void<void,void,void,void,void,void,void>
+ { static const int value=7; };
+
+#endif /*SIGC_TEMPLATE_SPECIALIZATION_MULTIPLE*/
+
+} /* namespace internal */
+
+
/** @defgroup bind bind(), bind_return()
* sigc::bind() alters an arbitrary functor by fixing arguments to certain values.
* Up to CALL_SIZE arguments can be bound at a time.
diff --git a/sigc++config.h.in b/sigc++config.h.in
index 180228e..686769d 100644
--- a/sigc++config.h.in
+++ b/sigc++config.h.in
@@ -1,4 +1,4 @@
/* config.h.in. Generated from configure.ac by autoheader. */
#undef SIGC_TEMPLATE_SPECIALIZATION_OPERATOR_OVERLOAD
-
+#undef SIGC_TEMPLATE_SPECIALIZATION_MULTIPLE