Skip to content
Snippets Groups Projects
Commit 41a83732 authored by Steffen Müthing's avatar Steffen Müthing
Browse files

[Build System] Add test for C++11 initializer list

parent 892d2043
No related branches found
No related tags found
No related merge requests found
......@@ -288,4 +288,27 @@ CHECK_CXX_SOURCE_COMPILES("
}
" HAVE_RVALUE_REFERENCES
)
# initializer list
CHECK_CXX_SOURCE_COMPILES("
#include <initializer_list>
#include <vector>
struct A
{
A(std::initializer_list<int> il)
: vec(il)
{}
std::vector<int> vec;
};
int main(void)
{
A a{1,3,4,5};
return 0;
}
" HAVE_INITIALIZER_LIST
)
cmake_pop_check_state()
......@@ -154,6 +154,9 @@
/* Define to 1 if rvalue references are supported */
#cmakedefine HAVE_RVALUE_REFERENCES 1
/* Define to 1 if initializer list is supported */
#cmakedefine HAVE_INITIALIZER_LIST 1
/* Include always useful headers */
#include <dune/common/deprecated.hh>
#include <dune/common/unused.hh>
......
......@@ -13,6 +13,7 @@ install(PROGRAMS
cxx0x_static_assert.m4
cxx0x_variadic.m4
cxx0x_variadic_constructor_sfinae.m4
cxx11_initializer_list.m4
dune.m4
dune_all.m4
dune_autobuild.m4
......
......@@ -17,6 +17,7 @@ ALLM4S = \
cxx0x_static_assert.m4 \
cxx0x_variadic.m4 \
cxx0x_variadic_constructor_sfinae.m4 \
cxx11_initializer_list.m4 \
dune.m4 \
dune_all.m4 \
dune_autobuild.m4 \
......
# tests for C++11 initializer list support
# the associated macro is called HAVE_INITIALIZER_LIST
AC_DEFUN([INITIALIZER_LIST_CHECK],[
AC_CACHE_CHECK([whether std::initializer_list is supported], dune_cv_initializer_list_support, [
AC_REQUIRE([AC_PROG_CXX])
AC_REQUIRE([GXX0X])
AC_LANG_PUSH([C++])
AC_RUN_IFELSE([
AC_LANG_PROGRAM([
#include <initializer_list>
#include <vector>
struct A
{
A(std::initializer_list<int> il)
: vec(il)
{}
std::vector<int> vec;
};
],
[
A a{1,3,4,5};
return 0;
])],
dune_cv_initializer_list_support=yes,
dune_cv_initializer_list_support=no)
AC_LANG_POP
])
if test "x$dune_cv_initializer_list_support" = xyes; then
AC_DEFINE(HAVE_INITIALIZER_LIST, 1, [Define to 1 if std::initializer_list is supported])
fi
])
......@@ -24,6 +24,7 @@ AC_DEFUN([DUNE_COMMON_CHECKS],
AC_REQUIRE([SHARED_PTR])
AC_REQUIRE([VARIADIC_TEMPLATES_CHECK])
AC_REQUIRE([RVALUE_REFERENCES_CHECK])
AC_REQUIRE([INITIALIZER_LIST_CHECK])
AC_REQUIRE([DUNE_BOOST_BASE])
AC_REQUIRE([MAKE_SHARED])
AC_REQUIRE([DUNE_LINKCXX])
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment