From b6c531f7c159a685eb71ad6a93d8308793a4f61b Mon Sep 17 00:00:00 2001 From: Stefan Reinhold Date: Fri, 3 Aug 2018 19:39:12 +0200 Subject: [PATCH] Explicitly check for availability of std::byte (fixes #713) (#714) * Explicitly check for availbility of std::byte GCC > 7.3 defines __cpp_lib_byte >= 201603 when std::byte is available. On libc++ std::byte is available since version 5.0. This can be checked with _LIBCPP_VERSION >= 5000. This fixes 713. * Add missing \ in preprocessor check --- include/gsl/gsl_byte | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/include/gsl/gsl_byte b/include/gsl/gsl_byte index e861173..6b770fd 100644 --- a/include/gsl/gsl_byte +++ b/include/gsl/gsl_byte @@ -43,16 +43,23 @@ #ifndef GSL_USE_STD_BYTE // this tests if we are under GCC or Clang with enough -std:c++1z power to get us std::byte -#if defined(__cplusplus) && (__cplusplus >= 201703L) +// also check if libc++ version is sufficient (> 5.0) or libstc++ actually contains std::byte +#if defined(__cplusplus) && (__cplusplus >= 201703L) && \ + (defined(__cpp_lib_byte) && (__cpp_lib_byte >= 201603) || \ + defined(_LIBCPP_VERSION) && (_LIBCPP_VERSION >= 5000)) #define GSL_USE_STD_BYTE 1 #include -#else // defined(__cplusplus) && (__cplusplus >= 201703L) +#else // defined(__cplusplus) && (__cplusplus >= 201703L) && + // (defined(__cpp_lib_byte) && (__cpp_lib_byte >= 201603) || + // defined(_LIBCPP_VERSION) && (_LIBCPP_VERSION >= 5000)) #define GSL_USE_STD_BYTE 0 #endif //defined(__cplusplus) && (__cplusplus >= 201703L) + // (defined(__cpp_lib_byte) && (__cpp_lib_byte >= 201603) || + // defined(_LIBCPP_VERSION) && (_LIBCPP_VERSION >= 5000)) #endif // GSL_USE_STD_BYTE #endif // _MSC_VER