Adding support for in-place use of ProducerConsumerQueue.
[folly.git] / folly / m4 / ac_cxx_compile_stdcxx_0x.m4
1 # ===========================================================================
2 #        http://autoconf-archive.cryp.to/ac_cxx_compile_stdcxx_0x.html
3 # ===========================================================================
4 #
5 # SYNOPSIS
6 #
7 #   AC_CXX_COMPILE_STDCXX_0X
8 #
9 # DESCRIPTION
10 #
11 #   Check for baseline language coverage in the compiler for the C++0x
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_0X], [
27   AC_CACHE_CHECK(if g++ supports C++0x features without additional flags,
28   ac_cv_cxx_compile_cxx0x_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
43     typedef check<int> check_type;
44     check_type c;
45     check_type&& cr = static_cast<check_type&&>(c);],,
46   ac_cv_cxx_compile_cxx0x_native=yes, ac_cv_cxx_compile_cxx0x_native=no)
47   AC_LANG_RESTORE
48   ])
49
50   AC_CACHE_CHECK(if g++ supports C++0x features with -std=c++0x,
51   ac_cv_cxx_compile_cxx0x_cxx,
52   [AC_LANG_SAVE
53   AC_LANG_CPLUSPLUS
54   ac_save_CXXFLAGS="$CXXFLAGS"
55   CXXFLAGS="$CXXFLAGS -std=c++0x"
56   AC_TRY_COMPILE([
57   template <typename T>
58     struct check
59     {
60       static_assert(sizeof(int) <= sizeof(T), "not big enough");
61     };
62
63     typedef check<check<bool>> right_angle_brackets;
64
65     int a;
66     decltype(a) b;
67
68     typedef check<int> check_type;
69     check_type c;
70     check_type&& cr = static_cast<check_type&&>(c);],,
71   ac_cv_cxx_compile_cxx0x_cxx=yes, ac_cv_cxx_compile_cxx0x_cxx=no)
72   CXXFLAGS="$ac_save_CXXFLAGS"
73   AC_LANG_RESTORE
74   ])
75
76   AC_CACHE_CHECK(if g++ supports C++0x features with -std=gnu++0x,
77   ac_cv_cxx_compile_cxx0x_gxx,
78   [AC_LANG_SAVE
79   AC_LANG_CPLUSPLUS
80   ac_save_CXXFLAGS="$CXXFLAGS"
81   CXXFLAGS="$CXXFLAGS -std=gnu++0x"
82   AC_TRY_COMPILE([
83   template <typename T>
84     struct check
85     {
86       static_assert(sizeof(int) <= sizeof(T), "not big enough");
87     };
88
89     typedef check<check<bool>> right_angle_brackets;
90
91     int a;
92     decltype(a) b;
93
94     typedef check<int> check_type;
95     check_type c;
96     check_type&& cr = static_cast<check_type&&>(c);],,
97   ac_cv_cxx_compile_cxx0x_gxx=yes, ac_cv_cxx_compile_cxx0x_gxx=no)
98   CXXFLAGS="$ac_save_CXXFLAGS"
99   AC_LANG_RESTORE
100   ])
101
102   if test "$ac_cv_cxx_compile_cxx0x_native" = yes ||
103      test "$ac_cv_cxx_compile_cxx0x_cxx" = yes ||
104      test "$ac_cv_cxx_compile_cxx0x_gxx" = yes; then
105     AC_DEFINE(HAVE_STDCXX_0X,,[Define if g++ supports C++0x features. ])
106   else
107     AC_MSG_ERROR([Could not find cxx0x support in g++])                         
108   fi
109 ])
110