Require C++17

Add a test that requires <any> header.

Update documentation.

Remove test for C++14.

Typical gcc version we have in mind is gcc 8.
This commit is contained in:
Jean-Marc Lasgouttes 2024-10-22 17:03:18 +02:00
parent 4155452ce4
commit c916bd1502
3 changed files with 16 additions and 19 deletions

View File

@ -52,7 +52,7 @@ You will also probably need GNU m4 (perhaps installed as gm4).
Requirements
------------
First of all, you will need a C++11 standard conforming compiler, like
First of all, you will need a C++17 standard conforming compiler, like
g++ (at least 5.0, to have proper std::regex & std::string) or
clang++.

View File

@ -161,12 +161,12 @@ fi
])
dnl Usage: LYX_CXX_CXX11_FLAGS(VERSION): add to AM_CXXFLAGS the best flag that
dnl selects C++11 mode; gives an error when C++11 mode is not found.
dnl VERSION is a list of years to try (e.g. 11 or {14,11}).
AC_DEFUN([LYX_CXX_CXX11_FLAGS],
[AC_CACHE_CHECK([for a good C++ mode], [lyx_cv_cxx11_flags],
[lyx_cv_cxx11_flags=none
dnl Usage: LYX_CXX_CXX17_FLAGS(VERSION): add to AM_CXXFLAGS the best flag that
dnl selects C++17 mode; gives an error when C++17 mode is not found.
dnl VERSION is a list of years to try (e.g. 17 or {20,17}).
AC_DEFUN([LYX_CXX_CXX17_FLAGS],
[AC_CACHE_CHECK([for a good C++ mode], [lyx_cv_cxx17_flags],
[lyx_cv_cxx17_flags=none
for flag in `eval echo -std=c++$1 default -std=gnu++$1` ; do
if test $flag = default ; then
flag=
@ -199,14 +199,17 @@ AC_DEFUN([LYX_CXX_CXX11_FLAGS],
check_type c;
check_type&& cr = static_cast<check_type&&>(c);
auto d = a;]], [[]])],[lyx_cv_cxx11_flags=$flag; break],[])
auto d = a;
#include <any>
std::any any_var = 10;]], [[]])],[lyx_cv_cxx17_flags=$flag; break],[])
CXXFLAGS=$save_CXXFLAGS
CPPFLAGS=$save_CPPFLAGS
done])
if test x$lyx_cv_cxx11_flags = xnone ; then
if test x$lyx_cv_cxx17_flags = xnone ; then
AC_MSG_ERROR([Cannot find suitable mode for compiler $CXX])
fi
AM_CXXFLAGS="$lyx_cv_cxx11_flags $AM_CXXFLAGS"
AM_CXXFLAGS="$lyx_cv_cxx17_flags $AM_CXXFLAGS"
])
@ -228,13 +231,13 @@ AC_REQUIRE([AC_PROG_CXXCPP])
### We might want to force the C++ standard.
AC_ARG_ENABLE(cxx-mode,
AS_HELP_STRING([--enable-cxx-mode],[choose C++ standard (default: 17, 14, then 11)]),,
[enable_cxx_mode={17,14,11}]
AS_HELP_STRING([--enable-cxx-mode],[choose C++ standard (default: 17)]),,
[enable_cxx_mode={17}]
)
AC_LANG_PUSH(C++)
LYX_PROG_CLANG
LYX_CXX_CXX11_FLAGS($enable_cxx_mode)
LYX_CXX_CXX17_FLAGS($enable_cxx_mode)
LYX_LIB_STDCXX
AC_LANG_POP(C++)

View File

@ -80,13 +80,7 @@ Changer MetricsBase::changeFontSet(string const & name)
&& ((isTextFont(oldname) && oldcolor != Color_foreground)
|| (isMathFont(oldname) && oldcolor != Color_math)))
font.setColor(oldcolor);
#if __cplusplus >= 201402L
return rc;
#else
/** In theory, this is not needed with C++11, and modern compilers
* will complain in C++11 mode, but gcc 4.9 requires this. */
return std::move(rc);
#endif
}