diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2025-04-10 12:21:26 +0100 |
---|---|---|
committer | Jonathan Wakely <redi@gcc.gnu.org> | 2025-04-11 13:17:15 +0100 |
commit | 648d5c26e25497249e1d381449f2bf66418b997c (patch) | |
tree | dd6cd8821fd8a0e21ec7a8c29ac5c02e6cbd42b7 /gcc | |
parent | ae54d8cb51eb5cc1f5a3d319cc1840d2e9bfcbfc (diff) | |
download | gcc-648d5c26e25497249e1d381449f2bf66418b997c.zip gcc-648d5c26e25497249e1d381449f2bf66418b997c.tar.gz gcc-648d5c26e25497249e1d381449f2bf66418b997c.tar.bz2 |
libstdc++: Use constexpr-if for std::basic_string::_S_copy_chars
For C++11 and later we can remove four overloads of _S_copy_chars and
use constexpr-if in the generic _S_copy_chars. This simplifies overload
resolution for _S_copy_chars, and also means that we use the optimized
memcpy path for other iterators such as std::vector<char>::iterator.
We still need all the _S_copy_chars overloads to be part of the explicit
instantiation definition, so make them depend on the macro that is
defined by src/c++11/string-inst.cc for that purpose.
For C++98 the _S_copy_chars overloads are still needed, but the macros
_GLIBCXX_NOEXCEPT and _GLIBCXX20_CONSTEXPR do nothing for C++98, so this
change removes them from those overloads. When instantiated in
src/c++11/string-inst.cc the removed _GLIBCXX_NOEXCEPT macros would
expand to 'noexcept', but in practice that doesn't make any difference
for those instantiations. At -O2 the instantiations inline all the calls
to _S_copy_chars and the presence or absence of noexcept doesn't change
anything in the generated code.
libstdc++-v3/ChangeLog:
* include/bits/basic_string.h (_S_copy_chars): Replace overloads
with constexpr-if and extend optimization to all contiguous
iterators.
* src/c++11/string-inst.cc: Extend comment.
Reviewed-by: Tomasz Kaminski <tkaminsk@redhat.com>
Diffstat (limited to 'gcc')
0 files changed, 0 insertions, 0 deletions