summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMurray Cumming <murrayc@murrayc.com>2004-03-13 23:09:43 +0000
committerMurray Cumming <murrayc@src.gnome.org>2004-03-13 23:09:43 +0000
commitb74c642a6703a1e40711547af50251b55cea79c4 (patch)
tree87259591f27b91224dda84b673f69aee0af64586
parent88928f22fa558353bcdb44171f70bdf2a53e91b2 (diff)
downloadglibmm-b74c642a6703a1e40711547af50251b55cea79c4.tar.gz
Added CAN_DISAMBIGUATE_CONST_TEMPLATE_SPECIALIZATIONS m4 macro to use in
2004-03-14 Murray Cumming <murrayc@murrayc.com> * scripts/cxx.m4: Added CAN_DISAMBIGUATE_CONST_TEMPLATE_SPECIALIZATIONS m4 macro to use in configure.in, to check for the SUN Forte problem - see the comments in cxx.m4. * scripts/sun.m4: Moved some brackets around to make the define actually work.
-rw-r--r--ChangeLog8
-rw-r--r--configure.in1
-rw-r--r--glib/glibmmconfig.h.in1
-rw-r--r--scripts/cxx.m470
-rw-r--r--scripts/cxx_std.m41
-rw-r--r--scripts/sun.m415
6 files changed, 88 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index d723e615..a5e1c578 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2004-03-14 Murray Cumming <murrayc@murrayc.com>
+
+ * scripts/cxx.m4: Added CAN_DISAMBIGUATE_CONST_TEMPLATE_SPECIALIZATIONS
+ m4 macro to use in configure.in, to check for the SUN Forte problem -
+ see the comments in cxx.m4.
+ * scripts/sun.m4: Moved some brackets around to make the define
+ actually work.
+
2004-03-13 Murray Cumming <murrayc@murrayc.com>
* glib/glibmm/containerhandle_shared.h: TypeTraits to_cpp_type()
diff --git a/configure.in b/configure.in
index 07f5f729..51e5e83e 100644
--- a/configure.in
+++ b/configure.in
@@ -190,6 +190,7 @@ GLIBMM_CXX_HAS_STD_ITERATOR_TRAITS()
GLIBMM_CXX_HAS_SUN_REVERSE_ITERATOR()
GLIBMM_CXX_HAS_TEMPLATE_SEQUENCE_CTORS()
GLIBMM_CXX_MEMBER_FUNCTIONS_MEMBER_TEMPLATES()
+GLIBMM_CXX_CAN_DISAMBIGUATE_CONST_TEMPLATE_SPECIALIZATIONS()
# Create a list of input directories for Doxygen.
GTKMM_DOXYGEN_INPUT_SUBDIRS([glib])
diff --git a/glib/glibmmconfig.h.in b/glib/glibmmconfig.h.in
index ec7e329b..548a7d54 100644
--- a/glib/glibmmconfig.h.in
+++ b/glib/glibmmconfig.h.in
@@ -50,6 +50,7 @@
#undef GLIBMM_HAVE_STD_ITERATOR_TRAITS
#undef GLIBMM_HAVE_SUN_REVERSE_ITERATOR
#undef GLIBMM_HAVE_TEMPLATE_SEQUENCE_CTORS
+#undef GLIBMM_HAVE_DISAMBIGUOUS_CONST_TEMPLATE_SPECIALIZATIONS
#ifndef GLIBMM_HAVE_NAMESPACE_STD
# define GLIBMM_USING_STD(Symbol) namespace std { using ::Symbol; }
diff --git a/scripts/cxx.m4 b/scripts/cxx.m4
index f0d9df67..69603863 100644
--- a/scripts/cxx.m4
+++ b/scripts/cxx.m4
@@ -137,4 +137,74 @@ AC_TRY_COMPILE(
])
])
+## GLIBMM_CXX_CAN_DISAMBIGUATE_CONST_TEMPLATE_SPECIALIZATIONS()
+##
+## Check whether the compiler finds it ambiguous to have both
+## const and non-const template specializations,
+## The SUN Forte compiler has this problem, though we are
+## not 100% sure that it's a C++ standards violation.
+##
+AC_DEFUN([GLIBMM_CXX_CAN_DISAMBIGUATE_CONST_TEMPLATE_SPECIALIZATIONS],
+[
+ AC_REQUIRE([GLIBMM_CXX_HAS_NAMESPACE_STD])
+
+ AC_CACHE_CHECK(
+ [whether the compiler finds it ambiguous to have both const and non-const template specializations],
+ [gtkmm_cv_cxx_can_disambiguate_const_template_specializations],
+ [
+ AC_TRY_COMPILE(
+ [
+ #include <iostream>
+ ],[
+ template <class T> class Foo {};
+
+ template <typename T> class Traits {
+ public:
+ const char* whoami() {
+ return "generic template";
+ }
+ };
+
+ template <typename T> class Traits<Foo<T> > {
+ public:
+ const char* whoami() {
+ return "partial specialization for Foo<T>";
+ }
+ };
+
+ template <typename T> class Traits<Foo<const T> > {
+ public:
+ const char* whoami() {
+ return "partial specialization for Foo<const T>";
+ }
+ };
+
+ int main(int, char*[])
+ {
+ Traits<int> it;
+ Traits<Foo<int> > fit;
+ Traits<Foo<const int> > cfit;
+
+ std::cout << "Traits<int> --> "
+ << it.whoami() << std::endl;
+ std::cout << "Traits<Foo<int>> --> "
+ << fit.whoami() << std::endl;
+ std::cout << "Traits<Foo<const int >> --> "
+ << cfit.whoami() << std::endl;
+
+ return 0;
+ }
+ ],
+ [gtkmm_cv_cxx_can_disambiguate_const_template_specializations="yes"],
+ [gtkmm_cv_cxx_can_disambiguate_const_template_specializations="no"]
+ )
+ ])
+
+ if test "x${gtkmm_cv_cxx_can_disambiguate_const_template_specializations}" = "xyes"; then
+ {
+ AC_DEFINE([GLIBMM_HAVE_DISAMBIGUOUS_CONST_TEMPLATE_SPECIALIZATIONS],[1, [Defined if the compiler does not find it ambiguous to have both const and non-const template specializations]])
+ }
+ fi
+])
+
diff --git a/scripts/cxx_std.m4 b/scripts/cxx_std.m4
index b2fc50e7..1a36305c 100644
--- a/scripts/cxx_std.m4
+++ b/scripts/cxx_std.m4
@@ -151,3 +151,4 @@ AC_DEFUN([GLIBMM_CXX_HAS_TEMPLATE_SEQUENCE_CTORS],
fi
])
+
diff --git a/scripts/sun.m4 b/scripts/sun.m4
index 1ee12fda..2e78f37b 100644
--- a/scripts/sun.m4
+++ b/scripts/sun.m4
@@ -4,13 +4,12 @@ AC_DEFUN(GLIBMM_PROG_CXX_SUN,
ac_cv_prog_sun_cxx=yes
else
ac_cv_prog_sun_cxx=no
- fi
-
- if test "x${gtkmm_cv_cxx_has_namespace_std}" = "xyes"; then
- {
- AC_DEFINE([GLIBMM_COMPILER_SUN_FORTE],[1], [Defined when the SUN Forte C++ compiler is being used.])
- }
fi]
- )
- ]
+ )]
+
+ if test "x${gtkmm_cv_cxx_has_namespace_std}" = "xyes"; then
+ {
+ AC_DEFINE([GLIBMM_COMPILER_SUN_FORTE],[1], [Defined when the SUN Forte C++ compiler is being used.])
+ }
+ fi
)