From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2181) id 53FFB385842D; Mon, 11 Oct 2021 19:37:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 53FFB385842D MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jonathan Wakely To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r12-4328] libstdc++: Simplify std::basic_regex::assign X-Act-Checkin: gcc X-Git-Author: Jonathan Wakely X-Git-Refname: refs/heads/master X-Git-Oldrev: 45ba5426c129993704a73e6ace4016eaa950d7ee X-Git-Newrev: 247bac507e63b32d4dc23ef1c55f300aafea24c6 Message-Id: <20211011193733.53FFB385842D@sourceware.org> Date: Mon, 11 Oct 2021 19:37:33 +0000 (GMT) X-BeenThere: libstdc++-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libstdc++-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Oct 2021 19:37:33 -0000 https://gcc.gnu.org/g:247bac507e63b32d4dc23ef1c55f300aafea24c6 commit r12-4328-g247bac507e63b32d4dc23ef1c55f300aafea24c6 Author: Jonathan Wakely Date: Mon Oct 11 17:19:43 2021 +0100 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: --- libstdc++-v3/include/bits/regex.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) 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