public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jonathan Wakely <jwakely@redhat.com>
To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org
Subject: [PATCH] Add std::__is_byte<std::byte> specialization
Date: Wed, 27 Jun 2018 10:30:00 -0000	[thread overview]
Message-ID: <20180627103040.GA24423@redhat.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 374 bytes --]

	* 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.


[-- Attachment #2: patch.txt --]
[-- Type: text/plain, Size: 907 bytes --]

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.

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
   //

                 reply	other threads:[~2018-06-27 10:30 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180627103040.GA24423@redhat.com \
    --to=jwakely@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=libstdc++@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).