From: Jonathan Wakely <jwakely@redhat.com>
To: Tim Shen <timshen@google.com>
Cc: libstdc++ <libstdc++@gcc.gnu.org>, gcc-patches <gcc-patches@gcc.gnu.org>
Subject: Re: [Patch] Small refactor on <regex> _State<>
Date: Thu, 30 Jul 2015 10:30:00 -0000 [thread overview]
Message-ID: <20150730101152.GL13355@redhat.com> (raw)
In-Reply-To: <CAG4ZjN=7nOtAibqX0KQ_XKcS7jDC-8_K0wRb5DG0Em+NtQ5xgg@mail.gmail.com>
On 29/07/15 21:55 -0700, Tim Shen wrote:
>- typedef _Matcher<typename _TraitsT::char_type> _MatcherT;
>+ typedef _Matcher<_Char_type> _MatcherT;
>+ static_assert(sizeof(_MatcherT) == sizeof(_Matcher<char>),
>+ "The aussmption std::function<bool(char)> has "
>+ "the same size as std::function<bool(T)> is violated");
>+ static_assert(alignof(_MatcherT) == alignof(_Matcher<char>),
>+ "The aussmption std::function<bool(char)> has "
>+ "the same alignment as std::function<bool(T)> is violated");
Good idea adding these assertions, but "aussmption" :-)
In accordance with https://gcc.gnu.org/bugzilla/show_bug.cgi?id=41759
we should avoid negative wording ("X is not Y" or "X does not meet Y")
in static assertions, so maybe something like:
static_assert(alignof(_MatcherT) == alignof(_Matcher<char>),
"std::function<bool(T)> has the same size as "
"std::function<bool(char)>");
or:
static_assert(alignof(_MatcherT) == alignof(_Matcher<char>),
"std::function<bool(T)> must have the same size as "
"std::function<bool(char)>");
>- _MatcherT _M_matches; // for _S_opcode_match
>+ _MatcherT&
>+ _M_get_matcher()
>+ { return *reinterpret_cast<_MatcherT*>(this->_M_matcher_storage._M_addr()); }
>
>- explicit _State(_Opcode __opcode) : _State_base(__opcode) { }
>+ const _MatcherT&
>+ _M_get_matcher() const
>+ { return *reinterpret_cast<const _MatcherT*>(this->_M_matcher_storage._M_addr()); }
These can use static_cast, because _M_addr() returns void*
OK for trunk with those two tweaks, thanks!
prev parent reply other threads:[~2015-07-30 10:11 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CAG4ZjNnYLoCYnjNpkJYHa2Q-ux0KnKmVXBDUOa33xk29MzeTKA@mail.gmail.com>
2015-07-25 8:05 ` Tim Shen
[not found] ` <20150725153121.GW21787@redhat.com>
[not found] ` <CAG4ZjNnvm=QAwihOUvMLtOezYprtasaJOY3i-MhJV0Tf4z5mpg@mail.gmail.com>
2015-07-28 15:42 ` Jonathan Wakely
2015-07-29 8:43 ` Jonathan Wakely
2015-07-29 9:08 ` Tim Shen
2015-07-29 9:34 ` Jonathan Wakely
2015-07-30 5:29 ` Tim Shen
2015-07-30 6:20 ` Tim Shen
2015-07-30 10:30 ` Jonathan Wakely [this message]
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=20150730101152.GL13355@redhat.com \
--to=jwakely@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=libstdc++@gcc.gnu.org \
--cc=timshen@google.com \
/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).