aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorStefan Reinhold <stefan@sreinhold.com>2018-08-03 19:39:12 +0200
committerNeil MacIntosh <neilmac@fb.com>2018-08-03 10:39:12 -0700
commitb6c531f7c159a685eb71ad6a93d8308793a4f61b (patch)
treeb50d31e2d306baf2e6022781b03e876722339936 /include
parentf4a715816ceb2dc136e86a68b71f05a8773c8f2b (diff)
downloadplatform_external_Microsoft-GSL-b6c531f7c159a685eb71ad6a93d8308793a4f61b.tar.gz
platform_external_Microsoft-GSL-b6c531f7c159a685eb71ad6a93d8308793a4f61b.tar.bz2
platform_external_Microsoft-GSL-b6c531f7c159a685eb71ad6a93d8308793a4f61b.zip
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
Diffstat (limited to 'include')
-rw-r--r--include/gsl/gsl_byte11
1 files 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 <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
#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