This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Finish implementing P0426R1 "Constexpr for std::char_traits" for C++17
- From: Jonathan Wakely <jwakely at redhat dot com>
- To: Pedro Alves <palves at redhat dot com>
- Cc: libstdc++ at gcc dot gnu dot org, "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 13 Jun 2017 16:57:03 +0100
- Subject: Re: [PATCH] Finish implementing P0426R1 "Constexpr for std::char_traits" for C++17
- Authentication-results: sourceware.org; auth=none
- Authentication-results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com
- Authentication-results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=jwakely at redhat dot com
- Dkim-filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 5A6116611
- Dmarc-filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 5A6116611
- References: <0867f2ad-1381-fdda-2f03-2fdbd450faed@redhat.com> <defced1f-1130-15fb-10dc-98b0eb4645f4@redhat.com> <20170605142734.GO12306@redhat.com> <38d6cdc6-554a-6d0d-e76d-c7d340bf1e75@redhat.com>
On 12/06/17 23:28 +0100, Pedro Alves wrote:
On 06/05/2017 03:27 PM, Jonathan Wakely wrote:
Pedro, this is OK for trunk now we're in stage 1. Please go ahead and
commit it - thanks.
Thanks Jonathan. I've pushed it in now.
It's probably safe for gcc-7-branch too, but let's leave it on trunk
for a while first.
OK.
BTW, for extra thoroughness, to confirm we're handling both
const & non-const arrays correctly, I had written this testsuite
tweak too. Would you like to have this in?
Yes please, this looks useful.
@@ -98,7 +220,12 @@ static_assert( test_compare<std::char_traits<char32_t>>() );
static_assert( test_length<std::char_traits<char32_t>>() );
static_assert( test_find<std::char_traits<char32_t>>() );
-struct C { unsigned char c; };
+struct C
+{
+ C() = default;
+ constexpr C(auto c_) : c(c_) {}
Placeholder types as function parameters are non-standard, so this
would fail with -pedantic-errors.
How about:
struct C {
constexpr C(unsigned char c_ = 0) : c(c_) { }
unsigned char c;
};
+ unsigned char c;
+};
constexpr bool operator==(const C& c1, const C& c2) { return c1.c == c2.c; }
constexpr bool operator<(const C& c1, const C& c2) { return c1.c < c2.c; }
static_assert( test_assign<std::char_traits<C>>() );
--
2.5.5