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
This commit is contained in:
Stefan Reinhold 2018-08-03 19:39:12 +02:00 committed by Neil MacIntosh
parent f4a715816c
commit b6c531f7c1

View File

@ -43,16 +43,23 @@
#ifndef GSL_USE_STD_BYTE #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 // 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 #define GSL_USE_STD_BYTE 1
#include <cstddef> #include <cstddef>
#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 #define GSL_USE_STD_BYTE 0
#endif //defined(__cplusplus) && (__cplusplus >= 201703L) #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 // GSL_USE_STD_BYTE
#endif // _MSC_VER #endif // _MSC_VER