From b91bfb6fb08a1ae655cc3a4a1107ecfe8e029647 Mon Sep 17 00:00:00 2001
From: Christian Engwer <christi@dune-project.org>
Date: Sun, 30 Jan 2011 23:25:21 +0000
Subject: [PATCH] =?UTF-8?q?add=20an=20other=20cxx0x=20test=20(credits=20go?=
 =?UTF-8?q?=20to=20Steffen=20M=C3=BCthing)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

[[Imported from SVN: r6326]]
---
 m4/Makefile.am                          |  1 +
 m4/cxx0x_rvaluereference.m4             |  2 +-
 m4/cxx0x_variadic_constructor_sfinae.m4 | 54 +++++++++++++++++++++++++
 3 files changed, 56 insertions(+), 1 deletion(-)
 create mode 100644 m4/cxx0x_variadic_constructor_sfinae.m4

diff --git a/m4/Makefile.am b/m4/Makefile.am
index c5f6a6819..fce61b1ac 100644
--- a/m4/Makefile.am
+++ b/m4/Makefile.am
@@ -16,6 +16,7 @@ ALLM4S = 					\
 	cxx0x_nullptr.m4			\
 	cxx0x_static_assert.m4			\
 	cxx0x_variadic.m4			\
+	cxx0x_variadic_constructor_sfinae.m4    \
 	dune.m4					\
 	dune_all.m4				\
 	dune_autobuild.m4			\
diff --git a/m4/cxx0x_rvaluereference.m4 b/m4/cxx0x_rvaluereference.m4
index e244e5cc4..bd8ccb3c9 100644
--- a/m4/cxx0x_rvaluereference.m4
+++ b/m4/cxx0x_rvaluereference.m4
@@ -26,7 +26,7 @@ AC_DEFUN([RVALUE_REFERENCES_CHECK],[
     AC_MSG_RESULT(yes)], [
     HAVE_RVALUE_REFERENCES=no
     AC_MSG_RESULT(no)])
-  if test "x$HAVE_RVALUe_REFERENCES" = xyes; then
+  if test "x$HAVE_RVALUE_REFERENCES" = xyes; then
     AC_DEFINE(HAVE_RVALUE_REFERENCES, 1, [Define to 1 if rvalue references are supported])
   fi
   AC_LANG_POP
diff --git a/m4/cxx0x_variadic_constructor_sfinae.m4 b/m4/cxx0x_variadic_constructor_sfinae.m4
new file mode 100644
index 000000000..80b6b54d8
--- /dev/null
+++ b/m4/cxx0x_variadic_constructor_sfinae.m4
@@ -0,0 +1,54 @@
+# tests whether the compiler supports SFINAE on variadic template constructors
+# within template classes. GCC 4.3 fails this test.
+# the associated macro is called HAVE_VARIADIC_CONSTRUCTOR_SFINAE
+
+AC_DEFUN([VARIADIC_CONSTRUCTOR_SFINAE_CHECK],[
+  AC_REQUIRE([AC_PROG_CXX])
+  AC_REQUIRE([GXX0X])
+  AC_LANG_PUSH([C++])
+  AC_MSG_CHECKING([whether SFINAE on variadic template constructors is fully supported])
+  AC_RUN_IFELSE([
+    AC_LANG_PROGRAM([#include <cassert>
+      #include <functional>
+
+      template<typename... U>
+      struct A
+      {
+
+        template<typename... T,
+                 typename = typename std::enable_if<(sizeof...(T) < 2)>::type
+                 >
+        A(T... t)
+          : i(1)
+        {}
+
+        template<typename... T,
+                 typename = typename std::enable_if<(sizeof...(T) >= 2)>::type,
+                 typename = void
+                 >
+        A(T... t)
+          : i(-1)
+        {}
+
+        A()
+          : i(1)
+        {}
+
+        int i;
+      };],
+      [
+        assert( A<int>().i + 
+                A<int>(2).i + 
+                A<int>("foo",3.4).i + 
+                A<int>({2,5,6},'a',A<int>()).i == 0);
+        return 0;
+      ])],[
+    HAVE_VARIADIC_CONSTRUCTOR_SFINAE=yes
+    AC_MSG_RESULT(yes)], [
+    HAVE_VARIADIC_CONSTRUCTOR_SFINAE=no
+    AC_MSG_RESULT(no)])
+  if test "x$HAVE_VARIADIC_CONSTRUCTOR_SFINAE" = xyes; then
+    AC_DEFINE(HAVE_VARIADIC_CONSTRUCTOR_SFINAE, 1, [Define to 1 if SFINAE on variadic template constructors is fully supported])
+  fi
+  AC_LANG_POP
+])
-- 
GitLab