]> git.ipfire.org Git - thirdparty/squid.git/blobdiff - acinclude/ax_cxx_0x_types.m4
SourceFormat Enforcement
[thirdparty/squid.git] / acinclude / ax_cxx_0x_types.m4
index 6707805a03507f1561fcb0128dcbd76b8bdf28cf..4de3c4046f9e4cbae712a0424501f73e081b20f2 100644 (file)
@@ -1,4 +1,4 @@
-## Copyright (C) 1996-2015 The Squid Software Foundation and contributors
+## Copyright (C) 1996-2017 The Squid Software Foundation and contributors
 ##
 ## Squid software is distributed under GPLv2+ license and includes
 ## contributions from numerous individuals and organizations.
@@ -55,23 +55,51 @@ AC_DEFUN([AX_CXX_TYPE_UNIQUE_PTR],[
 AC_DEFUN([AX_CXX_TYPE_UNIFORM_DISTRIBUTIONS],[
   AC_REQUIRE([AC_PROG_CXX])
   AC_LANG_PUSH([C++])
-  AC_MSG_CHECKING([whether std::uniform_int_distribution<T> is supported])
-  AC_TRY_COMPILE([#include <random>],[std::uniform_int_distribution<int> c;], [
-    HAVE_UNIFORM_INT_DISTRIBUTION=yes
-    AC_MSG_RESULT(yes)], [
-    HAVE_UNIFORM_INT_DISTRIBUTION=no
-    AC_MSG_RESULT(no)])
-  if test "x$HAVE_UNIFORM_INT_DISTRIBUTION" = xno; then
-    AC_DEFINE(uniform_int_distributon, tr1::uniform_int, [Leave undefined if std::uniform_int_distribution<T> is supported])
-  fi
-  AC_MSG_CHECKING([whether std::uniform_real_distribution<T> is supported])
-  AC_TRY_COMPILE([#include <random>],[std::uniform_real_distribution<double> c;], [
-    HAVE_UNIFORM_REAL_DISTRIBUTION=yes
-    AC_MSG_RESULT(yes)], [
-    HAVE_UNIFORM_REAL_DISTRIBUTION=no
-    AC_MSG_RESULT(no)])
-  if test "x$HAVE_UNIFORM_REAL_DISTRIBUTION" = xno; then
-    AC_DEFINE(uniform_real_distributon, tr1::uniform_real, [Leave undefined if std::uniform_real_distribution<T> is supported])
-  fi
+  AC_CHECK_HEADERS(tr1/random)
+  AC_CACHE_CHECK([whether std::uniform_int_distribution<T> is supported],
+                 [squid_cv_std_uniform_int_distribution_works],[
+    AC_TRY_COMPILE([#include <random>],[std::uniform_int_distribution<int> c;],
+      [squid_cv_std_uniform_int_distribution_works=yes],
+      [squid_cv_std_uniform_int_distribution_works=no])
+    ])
+  SQUID_DEFINE_BOOL([HAVE_STD_UNIFORM_INT_DISTRIBUTION],
+      [$squid_cv_std_uniform_int_distribution_works],
+      [Define if c++11 std::uniform_int_distribution is supported])
+
+  AC_CACHE_CHECK([whether std::uniform_real_distribution<T> is supported],
+                 [squid_cv_std_uniform_real_distribution_works],[
+    AC_REQUIRE([AC_PROG_CXX])
+    AC_LANG_PUSH([C++])
+    AC_TRY_COMPILE([#include <random>],[std::uniform_real_distribution<double> c;],
+      [squid_cv_std_uniform_real_distribution_works=yes],
+      [squid_cv_std_uniform_real_distribution_works=no])
+    ])
+  SQUID_DEFINE_BOOL([HAVE_STD_UNIFORM_REAL_DISTRIBUTION],
+      [$squid_cv_std_uniform_real_distribution_works],
+      [Define if c++11 std::uniform_real_distribution is supported])
+
   AC_LANG_POP
 ])
+
+## SQUID_CXX_STD_UNDERLYING_TYPE
+## checks whether the std::underlying_type<enumType>::type trait exists
+AC_DEFUN([SQUID_CXX_STD_UNDERLYING_TYPE],[
+  AC_CACHE_CHECK([whether compiler supports std::underlying_type],
+    [squid_cv_have_std_underlying_type],[
+      AC_REQUIRE([AC_PROG_CXX])
+      AC_LANG_PUSH([C++])
+      AC_COMPILE_IFELSE([
+        AC_LANG_PROGRAM([
+#include <type_traits>
+enum class testEnum { one, two, three };
+        ],[
+        std::underlying_type<testEnum>::type testNum = 0;
+        ])],
+        [squid_cv_have_std_underlying_type=yes],
+        [squid_cv_have_std_underlying_type=no])
+      AC_LANG_POP
+  ])
+  SQUID_DEFINE_BOOL([HAVE_STD_UNDERLYING_TYPE],
+     [$squid_cv_have_std_underlying_type],
+     [Define if stdlibc support std::underlying_type for enums])
+])