ax_cpp11.m4 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. AC_DEFUN([AX_ISC_CPP11], [
  2. CXX_SAVED=$CXX
  3. feature=
  4. for retry in "none" "--std=c++11" "--std=c++0x" "--std=c++1x" "fail"; do
  5. if test "$retry" = "fail"; then
  6. AC_MSG_ERROR([$feature (a C++11 feature) is not supported])
  7. fi
  8. if test "$retry" != "none"; then
  9. AC_MSG_WARN([unsupported C++11 feature])
  10. AC_MSG_NOTICE([retrying by adding $retry to $CXX])
  11. CXX="$CXX_SAVED $retry"
  12. AC_MSG_CHECKING($retry support)
  13. AC_COMPILE_IFELSE(
  14. [AC_LANG_PROGRAM(
  15. [],
  16. [int myincr = 1;])],
  17. [AC_MSG_RESULT([yes])],
  18. [AC_MSG_RESULT([no])
  19. continue])
  20. fi
  21. AC_MSG_CHECKING(std::unique_ptr support)
  22. feature="std::unique_ptr"
  23. AC_COMPILE_IFELSE(
  24. [AC_LANG_PROGRAM(
  25. [#include <memory>],
  26. [std::unique_ptr<int> a;])],
  27. [AC_MSG_RESULT([yes])],
  28. [AC_MSG_RESULT([no])
  29. continue])
  30. AC_MSG_CHECKING(cbegin/cend support)
  31. feature="cbegin/cend"
  32. AC_COMPILE_IFELSE(
  33. [AC_LANG_PROGRAM(
  34. [#include <string>],
  35. [const std::string& s = "abcd";
  36. unsigned count = 0;
  37. for (std::string::const_iterator i = s.cbegin();
  38. i != s.cend(); ++i)
  39. if (*i == 'b')
  40. ++count;])],
  41. [AC_MSG_RESULT([yes])],
  42. [AC_MSG_RESULT([no])
  43. continue])
  44. AC_MSG_CHECKING(final method support)
  45. feature="final method"
  46. AC_COMPILE_IFELSE(
  47. [AC_LANG_PROGRAM(
  48. [class Foo {
  49. public:
  50. virtual ~Foo() {};
  51. virtual void bar() final;
  52. };],[])],
  53. [AC_MSG_RESULT([yes])],
  54. [AC_MSG_RESULT([no])
  55. continue])
  56. AC_MSG_CHECKING(aggregate initialization support)
  57. feature="aggregate initialization"
  58. AC_COMPILE_IFELSE(
  59. [AC_LANG_PROGRAM(
  60. [#include <vector>],
  61. [std::vector<int> foo = { 1, 2, 3};])],
  62. [AC_MSG_RESULT([yes])],
  63. [AC_MSG_RESULT([no])
  64. continue])
  65. AC_MSG_CHECKING(variadic template support)
  66. feature="variadic template"
  67. AC_COMPILE_IFELSE(
  68. [AC_LANG_PROGRAM(
  69. [template<typename ... Args>
  70. struct A {
  71. void foo(Args... myargs) { return; };
  72. };],
  73. [A<> a;
  74. a.foo();])],
  75. [AC_MSG_RESULT([yes])],
  76. [AC_MSG_RESULT([no])
  77. continue])
  78. AC_MSG_CHECKING(static_assert support)
  79. feature="static_assert"
  80. AC_COMPILE_IFELSE(
  81. [AC_LANG_PROGRAM(
  82. [static_assert(1 + 1 == 2, "");],
  83. [])],
  84. [AC_MSG_RESULT([yes])],
  85. [AC_MSG_RESULT([no])
  86. continue])
  87. AC_MSG_CHECKING(template alias)
  88. feature="template alias"
  89. AC_COMPILE_IFELSE(
  90. [AC_LANG_PROGRAM(
  91. [template<int i>
  92. class I {
  93. public: int get() { return i; };
  94. };
  95. using Zero = I<0>;],
  96. [Zero Z;
  97. return Z.get();])],
  98. [AC_MSG_RESULT([yes])],
  99. [AC_MSG_RESULT([no])
  100. continue])
  101. AC_MSG_CHECKING(lambda support)
  102. feature="lambda"
  103. AC_COMPILE_IFELSE(
  104. [AC_LANG_PROGRAM(
  105. [],
  106. [auto myincr = [[]](int x) { return x + 1; };])],
  107. [AC_MSG_RESULT([yes])
  108. break],
  109. [AC_MSG_RESULT([no])
  110. continue])
  111. done
  112. ])dnl AX_ISC_RPATH