From: bangerth Date: Thu, 16 Jun 2011 20:17:08 +0000 (+0000) Subject: Check for a couple more C++11 features. X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f8060e9ce16e6a526e6659f4e280f2bd69cd85ae;p=dealii-svn.git Check for a couple more C++11 features. git-svn-id: https://svn.dealii.org/trunk@23829 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/aclocal.m4 b/deal.II/aclocal.m4 index c2077171e8..d45ce1fbd2 100644 --- a/deal.II/aclocal.m4 +++ b/deal.II/aclocal.m4 @@ -1006,14 +1006,14 @@ AC_DEFUN(DEAL_II_CHECK_CXX1X_COMPONENTS, dnl OLD_CXXFLAGS="$CXXFLAGS" CXXFLAGS="$1" - all_cxx1x_available=yes + all_cxx1x_classes_available=yes AC_MSG_CHECKING(for std::array) AC_TRY_COMPILE( [#include ], [ std::array p; p[0];], [ AC_MSG_RESULT(yes) ], - [ AC_MSG_RESULT(no); all_cxx1x_available=no ] + [ AC_MSG_RESULT(no); all_cxx1x_classes_available=no ] ) AC_MSG_CHECKING(for std::condition_variable) @@ -1021,7 +1021,7 @@ AC_DEFUN(DEAL_II_CHECK_CXX1X_COMPONENTS, dnl [#include ], [ std::condition_variable c; c.notify_all()], [ AC_MSG_RESULT(yes) ], - [ AC_MSG_RESULT(no); all_cxx1x_available=no ] + [ AC_MSG_RESULT(no); all_cxx1x_classes_available=no ] ) AC_MSG_CHECKING(for std::function and std::bind) @@ -1031,7 +1031,7 @@ AC_DEFUN(DEAL_II_CHECK_CXX1X_COMPONENTS, dnl [ std::function g = std::bind (f, std::placeholders::_1, 1.1) ;], [ AC_MSG_RESULT(yes) ], - [ AC_MSG_RESULT(no); all_cxx1x_available=no ] + [ AC_MSG_RESULT(no); all_cxx1x_classes_available=no ] ) dnl Make sure we don't run into GCC bug 35569 @@ -1043,7 +1043,7 @@ AC_DEFUN(DEAL_II_CHECK_CXX1X_COMPONENTS, dnl using namespace std::placeholders; bind(multiplies(),4,_1)(5); ;], [ AC_MSG_RESULT(yes) ], - [ AC_MSG_RESULT(no); all_cxx1x_available=no ] + [ AC_MSG_RESULT(no); all_cxx1x_classes_available=no ] ) AC_MSG_CHECKING(for std::shared_ptr) @@ -1051,7 +1051,7 @@ AC_DEFUN(DEAL_II_CHECK_CXX1X_COMPONENTS, dnl [#include ], [ std::shared_ptr p(new int(3))], [ AC_MSG_RESULT(yes) ], - [ AC_MSG_RESULT(no); all_cxx1x_available=no ] + [ AC_MSG_RESULT(no); all_cxx1x_classes_available=no ] ) AC_MSG_CHECKING(for std::thread) @@ -1060,7 +1060,7 @@ AC_DEFUN(DEAL_II_CHECK_CXX1X_COMPONENTS, dnl void f(int); ], [ std::thread t(f,1); t.join();], [ AC_MSG_RESULT(yes) ], - [ AC_MSG_RESULT(no); all_cxx1x_available=no ] + [ AC_MSG_RESULT(no); all_cxx1x_classes_available=no ] ) dnl On some systems with gcc 4.5.0, we can compile the code @@ -1076,7 +1076,7 @@ AC_DEFUN(DEAL_II_CHECK_CXX1X_COMPONENTS, dnl void f(int) {} int main() { std::thread t(f,1); t.join(); } ], [ AC_MSG_RESULT(yes) ], - [ AC_MSG_RESULT(no); all_cxx1x_available=no ] + [ AC_MSG_RESULT(no); all_cxx1x_classes_available=no ] ) CXXFLAGS="$1" @@ -1085,7 +1085,7 @@ AC_DEFUN(DEAL_II_CHECK_CXX1X_COMPONENTS, dnl [#include ], [ std::mutex m; m.lock();], [ AC_MSG_RESULT(yes) ], - [ AC_MSG_RESULT(no); all_cxx1x_available=no ] + [ AC_MSG_RESULT(no); all_cxx1x_classes_available=no ] ) AC_MSG_CHECKING(for std::tuple) @@ -1093,7 +1093,7 @@ AC_DEFUN(DEAL_II_CHECK_CXX1X_COMPONENTS, dnl [#include ], [ std::tuple p(1,1.1,'a')], [ AC_MSG_RESULT(yes) ], - [ AC_MSG_RESULT(no); all_cxx1x_available=no ] + [ AC_MSG_RESULT(no); all_cxx1x_classes_available=no ] ) CXXFLAGS="${OLD_CXXFLAGS}" @@ -1102,7 +1102,7 @@ AC_DEFUN(DEAL_II_CHECK_CXX1X_COMPONENTS, dnl dnl use the corresponding flag in CXXFLAGS* to switch on support and dnl correspondingly use the C++ classes instead of the BOOST classes AC_MSG_CHECKING(whether C++1x support is complete enough) - if test "x$all_cxx1x_available" = "xyes" ; then + if test "x$all_cxx1x_classes_available" = "xyes" ; then AC_MSG_RESULT(yes) CXXFLAGSG="$CXXFLAGSG $1" @@ -1110,6 +1110,45 @@ AC_DEFUN(DEAL_II_CHECK_CXX1X_COMPONENTS, dnl AC_DEFINE(DEAL_II_CAN_USE_CXX1X, 1, [Defined if the compiler we use supports the upcoming C++1x standard.]) + + + dnl Also test for a couple C++1x things that we don't use in the library + dnl but that users may want to use in their applications and that we + dnl might want to test in the testsuite + OLD_CXXFLAGS="$CXXFLAGS" + CXXFLAGS="$CXXFLAGSG" + + extra_cxx1x_features_available=yes + + AC_MSG_CHECKING(for auto typed variables) + AC_TRY_COMPILE( + [#include ], + [ + std::vector v; + auto i = v.begin(); + *i; + ], + [ AC_MSG_RESULT(yes) ], + [ AC_MSG_RESULT(no); extra_cxx1x_features_available=no ] + ) + + AC_MSG_CHECKING(for range-based for) + AC_TRY_COMPILE( + [#include ], + [ + std::vector v; + for (std::vector::iterator i : v) + *i; + ], + [ AC_MSG_RESULT(yes) ], + [ AC_MSG_RESULT(no); extra_cxx1x_features_available=no ] + ) + + CXXFLAGS="${OLD_CXXFLAGS}" + + dnl Right now, do nothing with this information since we don't + dnl have any compiler that gets all this right (gcc 4.5 included) + dnl and that we could use to test these features. else AC_MSG_RESULT(no) fi diff --git a/deal.II/configure b/deal.II/configure index 6c02220e8a..d1f15ddb2c 100755 --- a/deal.II/configure +++ b/deal.II/configure @@ -4112,7 +4112,7 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext OLD_CXXFLAGS="$CXXFLAGS" CXXFLAGS=""-std=c++0x"" - all_cxx1x_available=yes + all_cxx1x_classes_available=yes { $as_echo "$as_me:${as_lineno-$LINENO}: checking for std::array" >&5 $as_echo_n "checking for std::array... " >&6; } @@ -4132,7 +4132,7 @@ if ac_fn_cxx_try_compile "$LINENO"; then : $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; }; all_cxx1x_available=no +$as_echo "no" >&6; }; all_cxx1x_classes_available=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext @@ -4155,7 +4155,7 @@ if ac_fn_cxx_try_compile "$LINENO"; then : $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; }; all_cxx1x_available=no +$as_echo "no" >&6; }; all_cxx1x_classes_available=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext @@ -4180,7 +4180,7 @@ if ac_fn_cxx_try_compile "$LINENO"; then : $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; }; all_cxx1x_available=no +$as_echo "no" >&6; }; all_cxx1x_classes_available=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext @@ -4206,7 +4206,7 @@ if ac_fn_cxx_try_compile "$LINENO"; then : $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; }; all_cxx1x_available=no +$as_echo "no" >&6; }; all_cxx1x_classes_available=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext @@ -4229,7 +4229,7 @@ if ac_fn_cxx_try_compile "$LINENO"; then : $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; }; all_cxx1x_available=no +$as_echo "no" >&6; }; all_cxx1x_classes_available=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext @@ -4253,7 +4253,7 @@ if ac_fn_cxx_try_compile "$LINENO"; then : $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; }; all_cxx1x_available=no +$as_echo "no" >&6; }; all_cxx1x_classes_available=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext @@ -4278,7 +4278,7 @@ if ac_fn_cxx_try_run "$LINENO"; then : $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; }; all_cxx1x_available=no +$as_echo "no" >&6; }; all_cxx1x_classes_available=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ @@ -4305,7 +4305,7 @@ if ac_fn_cxx_try_compile "$LINENO"; then : $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; }; all_cxx1x_available=no +$as_echo "no" >&6; }; all_cxx1x_classes_available=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext @@ -4328,16 +4328,16 @@ if ac_fn_cxx_try_compile "$LINENO"; then : $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; }; all_cxx1x_available=no +$as_echo "no" >&6; }; all_cxx1x_classes_available=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext CXXFLAGS="${OLD_CXXFLAGS}" - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C++1x support is complete enough" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C++1x support is complete enough" >&5 $as_echo_n "checking whether C++1x support is complete enough... " >&6; } - if test "x$all_cxx1x_available" = "xyes" ; then + if test "x$all_cxx1x_classes_available" = "xyes" ; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } @@ -4347,6 +4347,68 @@ $as_echo "yes" >&6; } $as_echo "#define DEAL_II_CAN_USE_CXX1X 1" >>confdefs.h + + + OLD_CXXFLAGS="$CXXFLAGS" + CXXFLAGS="$CXXFLAGSG" + + extra_cxx1x_features_available=yes + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for auto typed variables" >&5 +$as_echo_n "checking for auto typed variables... " >&6; } + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main () +{ + + std::vector v; + auto i = v.begin(); + *i; + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; }; extra_cxx1x_features_available=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for range-based for" >&5 +$as_echo_n "checking for range-based for... " >&6; } + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main () +{ + + std::vector v; + for (std::vector::iterator i : v) + *i; + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; }; extra_cxx1x_features_available=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + + CXXFLAGS="${OLD_CXXFLAGS}" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; }