Add std::__is_byte<std::byte> specialization

Message ID 20180627103040.GA24423@redhat.com
State New
Headers show
Series
  • Add std::__is_byte<std::byte> specialization
Related show

Commit Message

Jonathan Wakely June 27, 2018, 10:30 a.m.
* include/bits/cpp_type_traits.h [__cplusplus >= 201703]
	(__is_byte<byte>): Define specialization for std::byte.

This is used in <algorithm> to decide whether to optimize fills to
memset, so we want to enable it for std::byte.

It could also be used to simplify __is_byte_like in <functional>,
which I might do at a later date.

Tested x86_64-linux, committed to trunk.
commit 4f1f2fba9a43e5f63cb771f7c9c358734bbbd92a
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Wed Jun 27 01:14:33 2018 +0100

    Add std::__is_byte<std::byte> specialization
    
            * include/bits/cpp_type_traits.h [__cplusplus >= 201703]
            (__is_byte<byte>): Define specialization for std::byte.

Patch

diff --git a/libstdc++-v3/include/bits/cpp_type_traits.h b/libstdc++-v3/include/bits/cpp_type_traits.h
index ed6de4696c7..960d469f412 100644
--- a/libstdc++-v3/include/bits/cpp_type_traits.h
+++ b/libstdc++-v3/include/bits/cpp_type_traits.h
@@ -391,6 +391,17 @@  __INT_N(__GLIBCXX_TYPE_INT_N_3)
       typedef __true_type __type;
     };
 
+#if __cplusplus >= 201703L
+  enum class byte : unsigned char;
+
+  template<>
+    struct __is_byte<byte>
+    {
+      enum { __value = 1 };
+      typedef __true_type __type;
+    };
+#endif // C++17
+
   //
   // Move iterator type
   //