]> git.ipfire.org Git - thirdparty/squid.git/blob - acinclude/ax_cxx_0x_types.m4
SourceFormat Enforcement
[thirdparty/squid.git] / acinclude / ax_cxx_0x_types.m4
1 ## Copyright (C) 1996-2017 The Squid Software Foundation and contributors
2 ##
3 ## Squid software is distributed under GPLv2+ license and includes
4 ## contributions from numerous individuals and organizations.
5 ## Please see the COPYING and CONTRIBUTORS files for details.
6 ##
7
8 ##
9 ## AX_CXX_TYPE_NULLPTR shamelessly copied from the DUNE sources under GPL version 2
10 ##
11 AC_DEFUN([AX_CXX_TYPE_NULLPTR],[
12 AC_REQUIRE([AC_PROG_CXX])
13 AC_LANG_PUSH([C++])
14 AC_MSG_CHECKING([whether nullptr is supported])
15 AC_TRY_COMPILE([],[char* ch = nullptr;], [
16 HAVE_NULLPTR=yes
17 AC_MSG_RESULT(yes)], [
18 HAVE_NULLPTR=no
19 AC_MSG_RESULT(no)])
20 if test "x$HAVE_NULLPTR" = xno; then
21 AC_DEFINE(nullptr, NULL, [Leave undefined if nullptr is supported])
22 fi
23 AC_MSG_CHECKING([whether nullptr_t is supported])
24 AC_TRY_COMPILE([#include <cstddef>],[typedef nullptr_t peng;], [
25 HAVE_NULLPTR_T=yes
26 AC_MSG_RESULT(yes)], [
27 HAVE_NULLPTR_T=no
28 AC_MSG_RESULT(no)])
29 if test "x$HAVE_NULLPTR_T" = xyes; then
30 AC_DEFINE(HAVE_NULLPTR_T, 1, [Define to 1 if nullptr_t is supported])
31 fi
32 AC_LANG_POP
33 ])
34
35 ## Hand crafted for Squid under GPL version 2
36 AC_DEFUN([AX_CXX_TYPE_UNIQUE_PTR],[
37 AC_REQUIRE([AC_PROG_CXX])
38 AC_LANG_PUSH([C++])
39 AC_MSG_CHECKING([whether std::unique_ptr<T> is supported])
40 AC_TRY_COMPILE([#include <memory>],[std::unique_ptr<char> c;], [
41 HAVE_UNIQUE_PTR=yes
42 AC_MSG_RESULT(yes)], [
43 HAVE_UNIQUE_PTR=no
44 AC_MSG_RESULT(no)])
45 if test "x$HAVE_UNIQUE_PTR" = xno; then
46 AC_DEFINE(unique_ptr, auto_ptr, [Leave undefined if std::unique_ptr<T> is supported])
47 fi
48 if test "x$HAVE_UNIQUE_PTR" = xyes; then
49 AC_DEFINE(HAVE_UNIQUE_PTR, 1, [Define to 1 if std::unique_ptr<T> is supported])
50 fi
51 AC_LANG_POP
52 ])
53
54 ## Hand crafted for Squid under GPL version 2
55 AC_DEFUN([AX_CXX_TYPE_UNIFORM_DISTRIBUTIONS],[
56 AC_REQUIRE([AC_PROG_CXX])
57 AC_LANG_PUSH([C++])
58 AC_CHECK_HEADERS(tr1/random)
59 AC_CACHE_CHECK([whether std::uniform_int_distribution<T> is supported],
60 [squid_cv_std_uniform_int_distribution_works],[
61 AC_TRY_COMPILE([#include <random>],[std::uniform_int_distribution<int> c;],
62 [squid_cv_std_uniform_int_distribution_works=yes],
63 [squid_cv_std_uniform_int_distribution_works=no])
64 ])
65 SQUID_DEFINE_BOOL([HAVE_STD_UNIFORM_INT_DISTRIBUTION],
66 [$squid_cv_std_uniform_int_distribution_works],
67 [Define if c++11 std::uniform_int_distribution is supported])
68
69 AC_CACHE_CHECK([whether std::uniform_real_distribution<T> is supported],
70 [squid_cv_std_uniform_real_distribution_works],[
71 AC_REQUIRE([AC_PROG_CXX])
72 AC_LANG_PUSH([C++])
73 AC_TRY_COMPILE([#include <random>],[std::uniform_real_distribution<double> c;],
74 [squid_cv_std_uniform_real_distribution_works=yes],
75 [squid_cv_std_uniform_real_distribution_works=no])
76 ])
77 SQUID_DEFINE_BOOL([HAVE_STD_UNIFORM_REAL_DISTRIBUTION],
78 [$squid_cv_std_uniform_real_distribution_works],
79 [Define if c++11 std::uniform_real_distribution is supported])
80
81 AC_LANG_POP
82 ])
83
84 ## SQUID_CXX_STD_UNDERLYING_TYPE
85 ## checks whether the std::underlying_type<enumType>::type trait exists
86 AC_DEFUN([SQUID_CXX_STD_UNDERLYING_TYPE],[
87 AC_CACHE_CHECK([whether compiler supports std::underlying_type],
88 [squid_cv_have_std_underlying_type],[
89 AC_REQUIRE([AC_PROG_CXX])
90 AC_LANG_PUSH([C++])
91 AC_COMPILE_IFELSE([
92 AC_LANG_PROGRAM([
93 #include <type_traits>
94 enum class testEnum { one, two, three };
95 ],[
96 std::underlying_type<testEnum>::type testNum = 0;
97 ])],
98 [squid_cv_have_std_underlying_type=yes],
99 [squid_cv_have_std_underlying_type=no])
100 AC_LANG_POP
101 ])
102 SQUID_DEFINE_BOOL([HAVE_STD_UNDERLYING_TYPE],
103 [$squid_cv_have_std_underlying_type],
104 [Define if stdlibc support std::underlying_type for enums])
105 ])