summaryrefslogtreecommitdiff
path: root/m4/ax_cxx_const_cast.m4
diff options
context:
space:
mode:
authorBastien ROUCARIÈS <roucaries.bastien@gmail.com>2014-12-29 13:14:42 +0100
committerBastien ROUCARIÈS <roucaries.bastien@gmail.com>2014-12-29 13:14:42 +0100
commit44b360ab0acdfb256b198137fb905d68893a0400 (patch)
tree55e1768c0b1cfaebdacad1cbaa9e8c08785c5cc7 /m4/ax_cxx_const_cast.m4
parent86c4a5204716eba81f652708d799359d9e6e5bd4 (diff)
downloadautoconf-archive-44b360ab0acdfb256b198137fb905d68893a0400.tar.gz
Modernize m4/ax_cxx_const_cast.m4
Diffstat (limited to 'm4/ax_cxx_const_cast.m4')
-rw-r--r--m4/ax_cxx_const_cast.m430
1 files changed, 18 insertions, 12 deletions
diff --git a/m4/ax_cxx_const_cast.m4 b/m4/ax_cxx_const_cast.m4
index 3029a10..4c6260f 100644
--- a/m4/ax_cxx_const_cast.m4
+++ b/m4/ax_cxx_const_cast.m4
@@ -20,19 +20,25 @@
# and this notice are preserved. This file is offered as-is, without any
# warranty.
-#serial 6
+#serial 7
AU_ALIAS([AC_CXX_CONST_CAST], [AX_CXX_CONST_CAST])
AC_DEFUN([AX_CXX_CONST_CAST],
-[AC_CACHE_CHECK(whether the compiler supports const_cast<>,
-ax_cv_cxx_const_cast,
-[AC_LANG_SAVE
- AC_LANG_CPLUSPLUS
- AC_TRY_COMPILE(,[int x = 0;const int& y = x;int& z = const_cast<int&>(y);return z;],
- ax_cv_cxx_const_cast=yes, ax_cv_cxx_const_cast=no)
- AC_LANG_RESTORE
-])
-if test "$ax_cv_cxx_const_cast" = yes; then
- AC_DEFINE(HAVE_CONST_CAST,,[define if the compiler supports const_cast<>])
-fi
+[dnl
+ AC_CACHE_CHECK([whether the compiler supports const_cast<>],
+ ax_cv_cxx_const_cast,
+ [dnl
+ AC_LANG_PUSH([C++])
+ AC_COMPILE_IFELSE([dnl
+ AC_LANG_PROGRAM([],
+ [int x = 0;
+ const int& y = x;
+ int& z = const_cast<int&>(y);
+ return z;])],
+ ax_cv_cxx_const_cast=yes,
+ ax_cv_cxx_const_cast=no)
+ AC_LANG_POP([C++])
+ ])
+ AS_IF([test "X$ax_cv_cxx_const_cast" = Xyes],
+ [AC_DEFINE(HAVE_CONST_CAST,,[define if the compiler supports const_cast<>])])
])