The recent SD-6 drafts define a macro for std::byte, so this patch
adds it.

        * include/c_global/cstddef: Define __cpp_lib_byte feature-test macro.
        * testsuite/18_support/byte/requirements.cc: Check macro.

Tested powerpc64le-linux, committed to trunk and gcc-7-branch.


commit 22d1d67abd32dc4db49519fbf24c7726999247fc
Author: Jonathan Wakely <jwak...@redhat.com>
Date:   Fri Oct 20 18:51:10 2017 +0100

    Define __cpp_lib_byte feature-test macro
    
            * include/c_global/cstddef: Define __cpp_lib_byte feature-test 
macro.
            * testsuite/18_support/byte/requirements.cc: Check macro.

diff --git a/libstdc++-v3/include/c_global/cstddef 
b/libstdc++-v3/include/c_global/cstddef
index 09754ee45da..11d268b7f81 100644
--- a/libstdc++-v3/include/c_global/cstddef
+++ b/libstdc++-v3/include/c_global/cstddef
@@ -57,9 +57,11 @@ namespace std
 }
 #endif
 
-#if __cplusplus > 201402L
+#if __cplusplus >= 201703L
 namespace std
 {
+#define __cpp_lib_byte 201603
+
   /// std::byte
   enum class byte : unsigned char {};
 
diff --git a/libstdc++-v3/testsuite/18_support/byte/requirements.cc 
b/libstdc++-v3/testsuite/18_support/byte/requirements.cc
index 4cb05df0405..74c8b64d6ce 100644
--- a/libstdc++-v3/testsuite/18_support/byte/requirements.cc
+++ b/libstdc++-v3/testsuite/18_support/byte/requirements.cc
@@ -20,6 +20,12 @@
 
 #include <cstddef>
 
+#ifndef __cpp_lib_byte
+# error "Feature-test macro for byte missing"
+#elif __cpp_lib_byte != 201603
+# error "Feature-test macro for byte has wrong value"
+#endif
+
 static_assert( sizeof(std::byte) == sizeof(unsigned char) );
 static_assert( alignof(std::byte) == alignof(unsigned char) );
 

Reply via email to