cxx_macros.m4 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. AC_DEFUN([AC_CXX_FUNCTION_NONTYPE_PARAMETERS],
  2. [AC_CACHE_CHECK(whether the compiler supports function templates with non-type parameters,
  3. ac_cv_cxx_function_nontype_parameters,
  4. [AC_LANG_SAVE
  5. AC_LANG_CPLUSPLUS
  6. AC_TRY_COMPILE([
  7. template<class T, int N> class A {};
  8. template<class T, int N> int f(const A<T,N>& x) { return 0; }
  9. ],[A<double, 17> z; return f(z);],
  10. ac_cv_cxx_function_nontype_parameters=yes, ac_cv_cxx_function_nontype_parameters=no)
  11. AC_LANG_RESTORE
  12. ])
  13. if test "$ac_cv_cxx_function_nontype_parameters" = yes; then
  14. AC_DEFINE(HAVE_FUNCTION_NONTYPE_PARAMETERS,,
  15. [define if the compiler supports function templates with non-type parameters])
  16. fi
  17. ])
  18. AC_DEFUN([AC_CXX_NAMESPACES],
  19. [AC_CACHE_CHECK(whether the compiler implements namespaces,
  20. ac_cv_cxx_namespaces,
  21. [AC_LANG_SAVE
  22. AC_LANG_CPLUSPLUS
  23. AC_TRY_COMPILE([namespace Outer { namespace Inner { int i = 0; }}],
  24. [using namespace Outer::Inner; return i;],
  25. ac_cv_cxx_namespaces=yes, ac_cv_cxx_namespaces=no)
  26. AC_LANG_RESTORE
  27. ])
  28. if test "$ac_cv_cxx_namespaces" = yes; then
  29. AC_DEFINE(HAVE_NAMESPACES,,[define if the compiler implements namespaces])
  30. fi
  31. ])
  32. AC_DEFUN([AC_CXX_HAVE_COMPLEX],
  33. [AC_CACHE_CHECK(whether the compiler has complex<T>,
  34. ac_cv_cxx_have_complex,
  35. [AC_REQUIRE([AC_CXX_NAMESPACES])
  36. AC_LANG_SAVE
  37. AC_LANG_CPLUSPLUS
  38. AC_TRY_COMPILE([#include <complex>
  39. #ifdef HAVE_NAMESPACES
  40. using namespace std;
  41. #endif],[complex<float> a; complex<double> b; return 0;],
  42. ac_cv_cxx_have_complex=yes, ac_cv_cxx_have_complex=no)
  43. AC_LANG_RESTORE
  44. ])
  45. if test "$ac_cv_cxx_have_complex" = yes; then
  46. AC_DEFINE(HAVE_COMPLEX,,[define if the compiler has complex<T>])
  47. fi
  48. ])
  49. AC_DEFUN([AC_CXX_HAVE_SSTREAM],
  50. [AC_CACHE_CHECK(whether the compiler has stringstream,
  51. ac_cv_cxx_have_sstream,
  52. [AC_REQUIRE([AC_CXX_NAMESPACES])
  53. AC_LANG_SAVE
  54. AC_LANG_CPLUSPLUS
  55. AC_TRY_COMPILE([#include <sstream>
  56. #ifdef HAVE_NAMESPACES
  57. using namespace std;
  58. #endif],[stringstream message; message << "Hello"; return 0;],
  59. ac_cv_cxx_have_sstream=yes, ac_cv_cxx_have_sstream=no)
  60. AC_LANG_RESTORE
  61. ])
  62. if test "$ac_cv_cxx_have_sstream" = yes; then
  63. AC_DEFINE(HAVE_SSTREAM,,[define if the compiler has stringstream])
  64. fi
  65. ])
  66. AC_DEFUN([AC_CXX_MUTABLE],
  67. [AC_CACHE_CHECK(whether the compiler supports the mutable keyword,
  68. ac_cv_cxx_mutable,
  69. [AC_LANG_SAVE
  70. AC_LANG_CPLUSPLUS
  71. AC_TRY_COMPILE([
  72. class A { mutable int i;
  73. public:
  74. int f (int n) const { i = n; return i; }
  75. };
  76. ],[A a; return a.f (1);],
  77. ac_cv_cxx_mutable=yes, ac_cv_cxx_mutable=no)
  78. AC_LANG_RESTORE
  79. ])
  80. if test "$ac_cv_cxx_mutable" = yes; then
  81. AC_DEFINE(HAVE_MUTABLE,,[define if the compiler supports the mutable keyword])
  82. fi
  83. ])