fix hazptr_array move
[folly.git] / folly / m4 / ac_cxx_compile_stdcxx_1y.m4
1 # ===========================================================================
2 #        http://autoconf-archive.cryp.to/ac_cxx_compile_stdcxx_0x.html
3 # ===========================================================================
4 #
5 # SYNOPSIS
6 #
7 #   AC_CXX_COMPILE_STDCXX_1Y
8 #
9 # DESCRIPTION
10 #
11 #   Check for baseline language coverage in the compiler for the C++1y
12 #   standard.
13 #
14 # LAST MODIFICATION
15 #
16 #   2008-04-17
17 #
18 # COPYLEFT
19 #
20 #   Copyright (c) 2008 Benjamin Kosnik <bkoz@redhat.com>
21 #
22 #   Copying and distribution of this file, with or without modification, are
23 #   permitted in any medium without royalty provided the copyright notice
24 #   and this notice are preserved.
25
26 AC_DEFUN([AC_CXX_COMPILE_STDCXX_1Y], [
27   AC_CACHE_CHECK(if g++ supports C++1y features without additional flags,
28   ac_cv_cxx_compile_cxx1y_native,
29   [AC_LANG_SAVE
30   AC_LANG_CPLUSPLUS
31   AC_TRY_COMPILE([
32   template <typename T>
33     struct check
34     {
35       static_assert(sizeof(int) <= sizeof(T), "not big enough");
36     };
37
38     typedef check<check<bool>> right_angle_brackets;
39
40     int a;
41     decltype(a) b;
42     auto f() {
43       int x = 0b01001;
44       return x;
45     }
46
47     typedef check<int> check_type;
48     check_type c;
49     check_type&& cr = static_cast<check_type&&>(c);],,
50   ac_cv_cxx_compile_cxx1y_native=yes, ac_cv_cxx_compile_cxx1y_native=no)
51   AC_LANG_RESTORE
52   ])
53
54   AC_CACHE_CHECK(if g++ supports C++1y features with -std=c++1y,
55   ac_cv_cxx_compile_cxx1y_cxx,
56   [AC_LANG_SAVE
57   AC_LANG_CPLUSPLUS
58   ac_save_CXXFLAGS="$CXXFLAGS"
59   CXXFLAGS="$CXXFLAGS -std=c++1y"
60   AC_TRY_COMPILE([
61   template <typename T>
62     struct check
63     {
64       static_assert(sizeof(int) <= sizeof(T), "not big enough");
65     };
66
67     typedef check<check<bool>> right_angle_brackets;
68
69     int a;
70     decltype(a) b;
71     auto f() {
72       int x = 0b01001;
73       return x;
74     }
75
76     typedef check<int> check_type;
77     check_type c;
78     check_type&& cr = static_cast<check_type&&>(c);],,
79   ac_cv_cxx_compile_cxx1y_cxx=yes, ac_cv_cxx_compile_cxx1y_cxx=no)
80   CXXFLAGS="$ac_save_CXXFLAGS"
81   AC_LANG_RESTORE
82   ])
83
84   AC_CACHE_CHECK(if g++ supports C++1y features with -std=gnu++1y,
85   ac_cv_cxx_compile_cxx1y_gxx,
86   [AC_LANG_SAVE
87   AC_LANG_CPLUSPLUS
88   ac_save_CXXFLAGS="$CXXFLAGS"
89   CXXFLAGS="$CXXFLAGS -std=gnu++1y"
90   AC_TRY_COMPILE([
91   template <typename T>
92     struct check
93     {
94       static_assert(sizeof(int) <= sizeof(T), "not big enough");
95     };
96
97     typedef check<check<bool>> right_angle_brackets;
98
99     int a;
100     decltype(a) b;
101     auto f() {
102       int x = 0b01001;
103       return x;
104     }
105
106     typedef check<int> check_type;
107     check_type c;
108     check_type&& cr = static_cast<check_type&&>(c);],,
109   ac_cv_cxx_compile_cxx1y_gxx=yes, ac_cv_cxx_compile_cxx1y_gxx=no)
110   CXXFLAGS="$ac_save_CXXFLAGS"
111   AC_LANG_RESTORE
112   ])
113
114   if test "$ac_cv_cxx_compile_cxx1y_native" = yes ||
115      test "$ac_cv_cxx_compile_cxx1y_cxx" = yes ||
116      test "$ac_cv_cxx_compile_cxx1y_gxx" = yes; then
117     AC_DEFINE(HAVE_STDCXX_1Y,,[Define if g++ supports C++1y features. ])
118   else
119     AC_MSG_ERROR([Could not find cxx1y support in g++])                         
120   fi
121 ])
122