From c9e931d69ef696ab752c1b719fba0baf60d978aa Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Fri, 20 Apr 2018 20:03:57 +0200 Subject: [PATCH] configure: add test for C++14 feature "user-defined literals for std::string" --- README.md | 10 +++++----- ac/c++-features.m4 | 31 +++++++++++++++++++++++++++++-- 2 files changed, 34 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index b9235a3f6..3675100a7 100644 --- a/README.md +++ b/README.md @@ -72,11 +72,11 @@ programs and libraries you absolutely need are: - A C++ compiler that supports several features of the C++11 and C++14 standards: initializer lists, range-based `for` loops, right angle - brackets, the `auto` keyword, lambda functions, the `nullptr` keyword, - tuples, alias declarations, `std::make_unique()`, digit - separators, binary literals and generic lambdas. Others may be - needed, too. For GCC this means at least v4.9.x; for clang v3.4 or - later. + brackets, the `auto` keyword, lambda functions, the `nullptr` + keyword, tuples, alias declarations, `std::make_unique()`, digit + separators, binary literals, generic lambdas, user-defined literals + for `std::string`. Others may be needed, too. For GCC this means at + least v5.x; for clang v3.4 or later. - [libEBML v1.3.5](http://dl.matroska.org/downloads/libebml/) or later and [libMatroska v1.4.8](http://dl.matroska.org/downloads/libmatroska/) diff --git a/ac/c++-features.m4 b/ac/c++-features.m4 index 886f77ae3..d7c0963af 100644 --- a/ac/c++-features.m4 +++ b/ac/c++-features.m4 @@ -349,6 +349,32 @@ AC_DEFUN([AX_CXX14_GENERIC_LAMBDAS],[ fi ]) +AC_DEFUN([AX_CXX14_USER_DEFINED_LITERALS_FOR_STD_STRING],[ + AC_CACHE_CHECK([for support for C++14 feature "User-defined literals for std::string"], [ax_cv_cxx14_user_defined_literals_for_std_string],[ + + CXXFLAGS_SAVED=$CXXFLAGS + CXXFLAGS="$CXXFLAGS $STD_CXX" + export CXXFLAGS + + AC_LANG_PUSH(C++) + AC_TRY_COMPILE( + [ +#include +using namespace std::string_literals; + ], + [return "hello"s.length();], + [ax_cv_cxx14_user_defined_literals_for_std_string="yes"], + [ax_cv_cxx14_user_defined_literals_for_std_string="no"]) + AC_LANG_POP + + CXXFLAGS="$CXXFLAGS_SAVED" + ]) + + if ! test x"$ax_cv_cxx14_user_defined_literals_for_std_string" = xyes ; then + missing_cxx_features="$missing_cxx_features\n * User-defined literals for std::string (C++14)" + fi +]) + dnl AC_DEFUN([AX_CXX14_DEF_NAME],[ dnl AC_CACHE_CHECK([for support for C++14 feature "human"], [ax_cv_cxx14_def_name],[ dnl @@ -385,10 +411,11 @@ AX_CXX14_MAKE_UNIQUE AX_CXX14_DIGIT_SEPARATORS AX_CXX14_BINARY_LITERALS AX_CXX14_GENERIC_LAMBDAS +AX_CXX14_USER_DEFINED_LITERALS_FOR_STD_STRING if test x"$missing_cxx_features" != x ; then printf "The following features of the C++11/C++14 standards are not supported by $CXX:$missing_cxx_features\n" - printf "If you are using the GNU C compiler collection (gcc) then you need\n" - printf "at least v4.9.x.\n" + printf "If you are using the GNU C compiler collection (gcc), you need\n" + printf "at least v5.x; for clang the 3.4 and newer should work.\n" AC_MSG_ERROR([support for required C++11/C++14 features incomplete]) fi