From: Jonathan Wakely <jwakely@redhat.com>
To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org
Subject: [committed] libstdc++: Simplify std::basic_regex::assign
Date: Mon, 11 Oct 2021 20:37:42 +0100 [thread overview]
Message-ID: <YWSShv4dsWb8gXGz@redhat.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 390 bytes --]
We know that if __is_contiguous_iterator is true then we have a pointer
or a __normal_iterator that wraps a pointer, so we don't need to use
std::__to_address.
libstdc++-v3/ChangeLog:
* include/bits/regex.h (basic_regex::assign(Iter, Iter)): Avoid
std::__to_address by using poitner directly or using base()
member of __normal_iterator.
Tested powerpc64le-linux. Committed to trunk.
[-- Attachment #2: patch.txt --]
[-- Type: text/plain, Size: 1610 bytes --]
commit 247bac507e63b32d4dc23ef1c55f300aafea24c6
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Mon Oct 11 17:19:43 2021
libstdc++: Simplify std::basic_regex::assign
We know that if __is_contiguous_iterator is true then we have a pointer
or a __normal_iterator that wraps a pointer, so we don't need to use
std::__to_address.
libstdc++-v3/ChangeLog:
* include/bits/regex.h (basic_regex::assign(Iter, Iter)): Avoid
std::__to_address by using poitner directly or using base()
member of __normal_iterator.
diff --git a/libstdc++-v3/include/bits/regex.h b/libstdc++-v3/include/bits/regex.h
index 3c44bcd7e33..a3990183580 100644
--- a/libstdc++-v3/include/bits/regex.h
+++ b/libstdc++-v3/include/bits/regex.h
@@ -682,15 +682,16 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
assign(_InputIterator __first, _InputIterator __last,
flag_type __flags = ECMAScript)
{
-#if __cplusplus >= 201703L
+#if __cpp_if_constexpr >= 201606L
using _ValT = typename iterator_traits<_InputIterator>::value_type;
if constexpr (__detail::__is_contiguous_iter<_InputIterator>::value
&& is_same_v<_ValT, value_type>)
{
__glibcxx_requires_valid_range(__first, __last);
- const auto __len = __last - __first;
- const _Ch_type* __p = std::__to_address(__first);
- _M_compile(__p, __p + __len, __flags);
+ if constexpr (is_pointer_v<_InputIterator>)
+ _M_compile(__first, __last, __flags);
+ else // __normal_iterator<_T*, C>
+ _M_compile(__first.base(), __last.base(), __flags);
}
else
#endif
reply other threads:[~2021-10-11 19:37 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=YWSShv4dsWb8gXGz@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).