<feed xmlns='http://www.w3.org/2005/Atom'>
<title>gcc.git/libstdc++-v3/include/bits/basic_string.h, branch master</title>
<subtitle>Unnamed repository; edit this file 'description' to name the repository.
</subtitle>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/gcc.git/'/>
<entry>
<title>libstdc++: store the length after the store of the null character</title>
<updated>2025-11-19T17:14:05+00:00</updated>
<author>
<name>Andrew Pinski</name>
<email>andrew.pinski@oss.qualcomm.com</email>
</author>
<published>2025-11-18T20:57:24+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/gcc.git/commit/?id=47ebad54abc127934693e7ace75a3cb08d6bc36c'/>
<id>47ebad54abc127934693e7ace75a3cb08d6bc36c</id>
<content type='text'>
This improves the code generation slightly for std::string because of
aliasing. In many cases the length will be read again and the store of
the null character will cause the length to be re-read due to aliasing
requirements of the char type. So swapping around the stores will allow
the length not to have to be reloaded from memory and will allow
for more optimizations.

Bootstrapped and tested on x86_64-linux-gnu.

libstdc++-v3/ChangeLog:

	* include/bits/basic_string.h (basic_string::M_set_length): Swap
	around the order of traits_type::assign and _M_length so that
	_M_length is at the end.

Signed-off-by: Andrew Pinski &lt;andrew.pinski@oss.qualcomm.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This improves the code generation slightly for std::string because of
aliasing. In many cases the length will be read again and the store of
the null character will cause the length to be re-read due to aliasing
requirements of the char type. So swapping around the stores will allow
the length not to have to be reloaded from memory and will allow
for more optimizations.

Bootstrapped and tested on x86_64-linux-gnu.

libstdc++-v3/ChangeLog:

	* include/bits/basic_string.h (basic_string::M_set_length): Swap
	around the order of traits_type::assign and _M_length so that
	_M_length is at the end.

Signed-off-by: Andrew Pinski &lt;andrew.pinski@oss.qualcomm.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>libstdc++: Fix -Wformat warning in std::string</title>
<updated>2025-10-07T11:11:21+00:00</updated>
<author>
<name>Jonathan Wakely</name>
<email>jwakely@redhat.com</email>
</author>
<published>2025-10-01T12:31:59+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/gcc.git/commit/?id=3f2a291ef3a5bbf854454f2d2c8559d9f4cb292a'/>
<id>3f2a291ef3a5bbf854454f2d2c8559d9f4cb292a</id>
<content type='text'>
The __throw_out_of_range_fmt function works like fprintf and so the
arguments corresponding to %zu specifiers need to be size_t. The
std::basic_string&lt;C,T,A&gt;::size_type type is A::size_type which is not
necessarily size_t. Add explicit casts to avoid a -Wformat warning with
-Wsystem-headers.

libstdc++-v3/ChangeLog:

	* include/bits/basic_string.h (basic_string::_M_check): Cast
	size_type arguments to size_t.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The __throw_out_of_range_fmt function works like fprintf and so the
arguments corresponding to %zu specifiers need to be size_t. The
std::basic_string&lt;C,T,A&gt;::size_type type is A::size_type which is not
necessarily size_t. Add explicit casts to avoid a -Wformat warning with
-Wsystem-headers.

libstdc++-v3/ChangeLog:

	* include/bits/basic_string.h (basic_string::_M_check): Cast
	size_type arguments to size_t.
</pre>
</div>
</content>
</entry>
<entry>
<title>libstdc++: Remove spaces before function parameter list</title>
<updated>2025-06-02T17:24:30+00:00</updated>
<author>
<name>Jonathan Wakely</name>
<email>jwakely@redhat.com</email>
</author>
<published>2025-05-29T10:33:54+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/gcc.git/commit/?id=0ec5306492be98ed1052e5ca9782f8966861e73a'/>
<id>0ec5306492be98ed1052e5ca9782f8966861e73a</id>
<content type='text'>
We don't use this GCC coding convention in libstdc++.

libstdc++-v3/ChangeLog:

	* include/bits/basic_string.h (basic_string::size): Remove space
	before parameter list.
	(basic_string::capacity): Likewise.
	* include/bits/stl_deque.h (deque::size): Likewise.
	* include/bits/stl_vector.h (vector::size, vector::capacity):
	Likewise.
	* include/bits/vector.tcc (vector::_M_realloc_insert): Likewise.
	(vector::_M_realloc_append): Likewise.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
We don't use this GCC coding convention in libstdc++.

libstdc++-v3/ChangeLog:

	* include/bits/basic_string.h (basic_string::size): Remove space
	before parameter list.
	(basic_string::capacity): Likewise.
	* include/bits/stl_deque.h (deque::size): Likewise.
	* include/bits/stl_vector.h (vector::size, vector::capacity):
	Likewise.
	* include/bits/vector.tcc (vector::_M_realloc_insert): Likewise.
	(vector::_M_realloc_append): Likewise.
</pre>
</div>
</content>
</entry>
<entry>
<title>libstdc++: Fix allocator propagation for rvalue+rvalue string concatenation</title>
<updated>2025-04-29T09:52:47+00:00</updated>
<author>
<name>Jonathan Wakely</name>
<email>jwakely@redhat.com</email>
</author>
<published>2025-04-28T13:31:04+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/gcc.git/commit/?id=025374559b22f5d9148f227b3df800a8e0231f59'/>
<id>025374559b22f5d9148f227b3df800a8e0231f59</id>
<content type='text'>
I made a last-minute change to Nina's r10-200-gf4e678ef74b272
implementation of P1165R1 (consistent allocator propagation for
operator+ on strings), so that the rvalue+rvalue case assumes that COW
strings do not support stateful allocators. I don't think that was true
when the change went in, and isn't true now. COW strings don't support
allocator propagation on assignment and swap, but they do support
non-equal stateful allocators, which are correctly propagated on move
construction.

This removes the preprocessor conditional in the rvalue+rvalue overload
so that COW strings are handled equivalently. Also use constexpr-if
unconditionally, disabling diagnostics with pragmas.

libstdc++-v3/ChangeLog:

	* include/bits/basic_string.h (operator+(string&amp;&amp;, string&amp;&amp;)):
	Do not assume that COW strings have equal allocators. Use
	constexpr-if unconditionally.
	* testsuite/21_strings/basic_string/allocator/char/operator_plus.cc:
	Remove cxx11_abi effective-target check.
	* testsuite/21_strings/basic_string/allocator/wchar_t/operator_plus.cc:
	Likewise.

Reviewed-by: Tomasz Kamiński &lt;tkaminsk@redhat.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
I made a last-minute change to Nina's r10-200-gf4e678ef74b272
implementation of P1165R1 (consistent allocator propagation for
operator+ on strings), so that the rvalue+rvalue case assumes that COW
strings do not support stateful allocators. I don't think that was true
when the change went in, and isn't true now. COW strings don't support
allocator propagation on assignment and swap, but they do support
non-equal stateful allocators, which are correctly propagated on move
construction.

This removes the preprocessor conditional in the rvalue+rvalue overload
so that COW strings are handled equivalently. Also use constexpr-if
unconditionally, disabling diagnostics with pragmas.

libstdc++-v3/ChangeLog:

	* include/bits/basic_string.h (operator+(string&amp;&amp;, string&amp;&amp;)):
	Do not assume that COW strings have equal allocators. Use
	constexpr-if unconditionally.
	* testsuite/21_strings/basic_string/allocator/char/operator_plus.cc:
	Remove cxx11_abi effective-target check.
	* testsuite/21_strings/basic_string/allocator/wchar_t/operator_plus.cc:
	Likewise.

Reviewed-by: Tomasz Kamiński &lt;tkaminsk@redhat.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>libstdc++: Fix std::string construction from volatile char* [PR119748]</title>
<updated>2025-04-15T08:24:58+00:00</updated>
<author>
<name>Jonathan Wakely</name>
<email>jwakely@redhat.com</email>
</author>
<published>2025-04-11T21:13:14+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/gcc.git/commit/?id=05d3aebe24be1177851574ab224f16492c5050fd'/>
<id>05d3aebe24be1177851574ab224f16492c5050fd</id>
<content type='text'>
My recent r15-9381-g648d5c26e25497 change assumes that a contiguous
iterator with the correct value_type can be converted to a const charT*
but that's not true for volatile charT*. The optimization should only be
done if it can be converted to the right pointer type.

Additionally, some generic loops for non-contiguous iterators need an
explicit cast to deal with iterator reference types that do not bind to
the const charT&amp; parameter of traits_type::assign.

libstdc++-v3/ChangeLog:

	PR libstdc++/119748
	* include/bits/basic_string.h (_S_copy_chars): Only optimize for
	contiguous iterators that are convertible to const charT*. Use
	explicit conversion to charT after dereferencing iterator.
	(_S_copy_range): Likewise for contiguous ranges.
	* include/bits/basic_string.tcc (_M_construct): Use explicit
	conversion to charT after dereferencing iterator.
	* include/bits/cow_string.h (_S_copy_chars): Likewise.
	(basic_string(from_range_t, R&amp;&amp;, const Allocator&amp;)): Likewise.
	Only optimize for contiguous iterators that are convertible to
	const charT*.
	* testsuite/21_strings/basic_string/cons/char/119748.cc: New
	test.
	* testsuite/21_strings/basic_string/cons/wchar_t/119748.cc:
	New test.

Reviewed-by: Tomasz Kaminski &lt;tkaminsk@redhat.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
My recent r15-9381-g648d5c26e25497 change assumes that a contiguous
iterator with the correct value_type can be converted to a const charT*
but that's not true for volatile charT*. The optimization should only be
done if it can be converted to the right pointer type.

Additionally, some generic loops for non-contiguous iterators need an
explicit cast to deal with iterator reference types that do not bind to
the const charT&amp; parameter of traits_type::assign.

libstdc++-v3/ChangeLog:

	PR libstdc++/119748
	* include/bits/basic_string.h (_S_copy_chars): Only optimize for
	contiguous iterators that are convertible to const charT*. Use
	explicit conversion to charT after dereferencing iterator.
	(_S_copy_range): Likewise for contiguous ranges.
	* include/bits/basic_string.tcc (_M_construct): Use explicit
	conversion to charT after dereferencing iterator.
	* include/bits/cow_string.h (_S_copy_chars): Likewise.
	(basic_string(from_range_t, R&amp;&amp;, const Allocator&amp;)): Likewise.
	Only optimize for contiguous iterators that are convertible to
	const charT*.
	* testsuite/21_strings/basic_string/cons/char/119748.cc: New
	test.
	* testsuite/21_strings/basic_string/cons/wchar_t/119748.cc:
	New test.

Reviewed-by: Tomasz Kaminski &lt;tkaminsk@redhat.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>libstdc++: Use constexpr-if for std::basic_string::_S_copy_chars</title>
<updated>2025-04-11T12:17:15+00:00</updated>
<author>
<name>Jonathan Wakely</name>
<email>jwakely@redhat.com</email>
</author>
<published>2025-04-10T11:21:26+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/gcc.git/commit/?id=648d5c26e25497249e1d381449f2bf66418b997c'/>
<id>648d5c26e25497249e1d381449f2bf66418b997c</id>
<content type='text'>
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&lt;char&gt;::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 &lt;tkaminsk@redhat.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
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&lt;char&gt;::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 &lt;tkaminsk@redhat.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>libstdc++: Define __cpp_lib_containers_ranges in appropriate headers [PR111055]</title>
<updated>2025-04-11T11:56:03+00:00</updated>
<author>
<name>Tomasz Kamiński</name>
<email>tkaminsk@redhat.com</email>
</author>
<published>2025-03-21T11:55:48+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/gcc.git/commit/?id=ae54d8cb51eb5cc1f5a3d319cc1840d2e9bfcbfc'/>
<id>ae54d8cb51eb5cc1f5a3d319cc1840d2e9bfcbfc</id>
<content type='text'>
This is final piece of P1206R7, adding a feature test macros,
as range constructors and member operations are now implemented for
all containers and adaptors.

For consistency with the proposal, all new container operations and
helpers are now defined if __glibcxx_containers_ranges, instead
of __glibcxx_ranges_to_container.

	PR libstdc++/111055

libstdc++-v3/ChangeLog:

	* include/bits/version.def (containers_ranges): Define.
	* include/bits/version.h: Regenerate.
	* include/bits/ranges_base.h (__detail::__container_compatible_range)
	(__detail::__range_to_alloc_type, __detail::__range_mapped_type)
	(__detail::__range_key_type): Depend on __glibcxx_containers_ranges
	instead of __glibcxx_ranges_to_container.
	* include/bits/basic_string.h: Replace __glibcxx_ranges_to_container with
	__glibcxx_containers_ranges.
	* include/bits/cow_string.h: Likewise.
	* include/bits/deque.tcc: Likewise.
	* include/bits/forward_list.h: Likewise.
	* include/bits/stl_bvector.h: Likewise.
	* include/bits/stl_deque.h: Likewise.
	* include/bits/stl_list.h: Likewise.
	* include/bits/stl_map.h: Likewise.
	* include/bits/stl_multimap.h: Likewise.
	* include/bits/stl_multiset.h: Likewise.
	* include/bits/stl_queue.h: Likewise.
	* include/bits/stl_set.h: Likewise.
	* include/bits/stl_stack.h: Likewise.
	* include/bits/stl_vector.h: Likewise.
	* include/bits/unordered_map.h: Likewise.
	* include/bits/unordered_set.h: Likewise.
	* include/bits/vector.tcc: Likewise.
	* include/debug/deque: Likewise.
	* include/debug/forward_list: Likewise.
	* include/debug/list: Likewise.
	* include/debug/map.h: Likewise.
	* include/debug/multimap.h: Likewise.
	* include/debug/multiset.h: Likewise.
	* include/debug/set.h: Likewise.
	* include/debug/unordered_map: Likewise.
	* include/debug/unordered_set: Likewise.
	* include/debug/vector: Likewise.
	* include/std/deque: Provide __cpp_lib_containers_ranges.
	* include/std/forward_list: Likewise.
	* include/std/list: Likewise.
	* include/std/map: Likewise.
	* include/std/queue: Likewise.
	* include/std/set: Likewise.
	* include/std/stack: Likewise.
	* include/std/string: Likewise.
	* include/std/unordered_map: Likewise.
	* include/std/unordered_set: Likewise.
	* include/std/vector: Likewise.
	* testsuite/21_strings/basic_string/cons/from_range.cc: Test for value
	__cpp_lib_containers_ranges.
	* testsuite/23_containers/deque/cons/from_range.cc: Likewise.
	* testsuite/23_containers/forward_list/cons/from_range.cc: Likewise.
	* testsuite/23_containers/list/cons/from_range.cc: Likewise.
	* testsuite/23_containers/map/cons/from_range.cc: Likewise.
	* testsuite/23_containers/multimap/cons/from_range.cc: Likewise.
	* testsuite/23_containers/multiset/cons/from_range.cc: Likewise.
	* testsuite/23_containers/priority_queue/cons_from_range.cc: Likewise.
	* testsuite/23_containers/queue/cons_from_range.cc: Likewise.
	* testsuite/23_containers/set/cons/from_range.cc: Likewise.
	* testsuite/23_containers/stack/cons_from_range.cc: Likewise.
	* testsuite/23_containers/unordered_map/cons/from_range.cc: Likewise.
	* testsuite/23_containers/unordered_multimap/cons/from_range.cc: Likewise.
	* testsuite/23_containers/unordered_multiset/cons/from_range.cc: Likewise.
	* testsuite/23_containers/unordered_set/cons/from_range.cc: Likewise.
	* testsuite/23_containers/vector/bool/cons/from_range.cc: Likewise.
	* testsuite/23_containers/vector/cons/from_range.cc: Likewise.

Reviewed-by: Jonathan Wakely &lt;jwakely@redhat.com&gt;
Signed-off-by: Tomasz Kamiński &lt;tkaminsk@redhat.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This is final piece of P1206R7, adding a feature test macros,
as range constructors and member operations are now implemented for
all containers and adaptors.

For consistency with the proposal, all new container operations and
helpers are now defined if __glibcxx_containers_ranges, instead
of __glibcxx_ranges_to_container.

	PR libstdc++/111055

libstdc++-v3/ChangeLog:

	* include/bits/version.def (containers_ranges): Define.
	* include/bits/version.h: Regenerate.
	* include/bits/ranges_base.h (__detail::__container_compatible_range)
	(__detail::__range_to_alloc_type, __detail::__range_mapped_type)
	(__detail::__range_key_type): Depend on __glibcxx_containers_ranges
	instead of __glibcxx_ranges_to_container.
	* include/bits/basic_string.h: Replace __glibcxx_ranges_to_container with
	__glibcxx_containers_ranges.
	* include/bits/cow_string.h: Likewise.
	* include/bits/deque.tcc: Likewise.
	* include/bits/forward_list.h: Likewise.
	* include/bits/stl_bvector.h: Likewise.
	* include/bits/stl_deque.h: Likewise.
	* include/bits/stl_list.h: Likewise.
	* include/bits/stl_map.h: Likewise.
	* include/bits/stl_multimap.h: Likewise.
	* include/bits/stl_multiset.h: Likewise.
	* include/bits/stl_queue.h: Likewise.
	* include/bits/stl_set.h: Likewise.
	* include/bits/stl_stack.h: Likewise.
	* include/bits/stl_vector.h: Likewise.
	* include/bits/unordered_map.h: Likewise.
	* include/bits/unordered_set.h: Likewise.
	* include/bits/vector.tcc: Likewise.
	* include/debug/deque: Likewise.
	* include/debug/forward_list: Likewise.
	* include/debug/list: Likewise.
	* include/debug/map.h: Likewise.
	* include/debug/multimap.h: Likewise.
	* include/debug/multiset.h: Likewise.
	* include/debug/set.h: Likewise.
	* include/debug/unordered_map: Likewise.
	* include/debug/unordered_set: Likewise.
	* include/debug/vector: Likewise.
	* include/std/deque: Provide __cpp_lib_containers_ranges.
	* include/std/forward_list: Likewise.
	* include/std/list: Likewise.
	* include/std/map: Likewise.
	* include/std/queue: Likewise.
	* include/std/set: Likewise.
	* include/std/stack: Likewise.
	* include/std/string: Likewise.
	* include/std/unordered_map: Likewise.
	* include/std/unordered_set: Likewise.
	* include/std/vector: Likewise.
	* testsuite/21_strings/basic_string/cons/from_range.cc: Test for value
	__cpp_lib_containers_ranges.
	* testsuite/23_containers/deque/cons/from_range.cc: Likewise.
	* testsuite/23_containers/forward_list/cons/from_range.cc: Likewise.
	* testsuite/23_containers/list/cons/from_range.cc: Likewise.
	* testsuite/23_containers/map/cons/from_range.cc: Likewise.
	* testsuite/23_containers/multimap/cons/from_range.cc: Likewise.
	* testsuite/23_containers/multiset/cons/from_range.cc: Likewise.
	* testsuite/23_containers/priority_queue/cons_from_range.cc: Likewise.
	* testsuite/23_containers/queue/cons_from_range.cc: Likewise.
	* testsuite/23_containers/set/cons/from_range.cc: Likewise.
	* testsuite/23_containers/stack/cons_from_range.cc: Likewise.
	* testsuite/23_containers/unordered_map/cons/from_range.cc: Likewise.
	* testsuite/23_containers/unordered_multimap/cons/from_range.cc: Likewise.
	* testsuite/23_containers/unordered_multiset/cons/from_range.cc: Likewise.
	* testsuite/23_containers/unordered_set/cons/from_range.cc: Likewise.
	* testsuite/23_containers/vector/bool/cons/from_range.cc: Likewise.
	* testsuite/23_containers/vector/cons/from_range.cc: Likewise.

Reviewed-by: Jonathan Wakely &lt;jwakely@redhat.com&gt;
Signed-off-by: Tomasz Kamiński &lt;tkaminsk@redhat.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>libstdc++: Add P1206R7 from_range members to std::string [PR111055]</title>
<updated>2025-04-11T10:18:30+00:00</updated>
<author>
<name>Jonathan Wakely</name>
<email>jwakely@redhat.com</email>
</author>
<published>2025-04-10T12:40:53+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/gcc.git/commit/?id=882d3b319dbf50ae64080731a1398031c100b7c7'/>
<id>882d3b319dbf50ae64080731a1398031c100b7c7</id>
<content type='text'>
This is the last piece of P1206R7, adding new members to
std::basic_string.

libstdc++-v3/ChangeLog:

	PR libstdc++/111055
	* include/bits/basic_string.h (_S_copy_range): New function.
	(basic_string(from_range_t, R%%, const Alloc&amp;)): New
	constructor.
	(append_range, assign_range, insert_range, replace_with_range):
	New functions.
	* include/bits/cow_string.h: Likewise.
	* testsuite/21_strings/basic_string/cons/from_range.cc: New
	test.
	* testsuite/21_strings/basic_string/modifiers/append/append_range.cc:
	New test.
	* testsuite/21_strings/basic_string/modifiers/assign/assign_range.cc:
	New test.
	* testsuite/21_strings/basic_string/modifiers/insert/insert_range.cc:
	New test.
	* testsuite/21_strings/basic_string/modifiers/replace/replace_with_range.cc:
	New test.

Co-authored-by: Tomasz Kamiński &lt;tkaminsk@redhat.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This is the last piece of P1206R7, adding new members to
std::basic_string.

libstdc++-v3/ChangeLog:

	PR libstdc++/111055
	* include/bits/basic_string.h (_S_copy_range): New function.
	(basic_string(from_range_t, R%%, const Alloc&amp;)): New
	constructor.
	(append_range, assign_range, insert_range, replace_with_range):
	New functions.
	* include/bits/cow_string.h: Likewise.
	* testsuite/21_strings/basic_string/cons/from_range.cc: New
	test.
	* testsuite/21_strings/basic_string/modifiers/append/append_range.cc:
	New test.
	* testsuite/21_strings/basic_string/modifiers/assign/assign_range.cc:
	New test.
	* testsuite/21_strings/basic_string/modifiers/insert/insert_range.cc:
	New test.
	* testsuite/21_strings/basic_string/modifiers/replace/replace_with_range.cc:
	New test.

Co-authored-by: Tomasz Kamiński &lt;tkaminsk@redhat.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>libstdc++: Check feature test macro for std::string_view in &lt;string&gt;</title>
<updated>2025-04-04T09:29:57+00:00</updated>
<author>
<name>Jonathan Wakely</name>
<email>jwakely@redhat.com</email>
</author>
<published>2025-04-03T12:59:14+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/gcc.git/commit/?id=affdef57a45a443ead24f6afb7027a2683028031'/>
<id>affdef57a45a443ead24f6afb7027a2683028031</id>
<content type='text'>
We can use the __glibcxx_string_view macro to guard the uses of
std::string_view in &lt;string&gt;, instead of just checking the value of
__cplusplus. It makes no practical difference because
__glibcxx_string_view is defined for C++17 and up, but it makes it clear
to readers that the lines guarded by that macro are features that depend
on string_view.

We could be more precise and check __glibcxx_string_view &gt;= 201606L
which is the value for the P0254R2 paper that integrated
std::string_view with std::string, but I think just checking for the
macro being defined is clear enough.

We can also check __glibcxx_variant for the _Never_valueless_alt partial
specialization.

libstdc++-v3/ChangeLog:

	* include/bits/basic_string.h: Check __glibcxx_string_view and
	__glibcxx_variant instead of __cplusplus &gt;= 2017L.
	* include/bits/cow_string.h: Likewise.

Reviewed-by: Tomasz Kamiński &lt;tkaminsk@redhat.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
We can use the __glibcxx_string_view macro to guard the uses of
std::string_view in &lt;string&gt;, instead of just checking the value of
__cplusplus. It makes no practical difference because
__glibcxx_string_view is defined for C++17 and up, but it makes it clear
to readers that the lines guarded by that macro are features that depend
on string_view.

We could be more precise and check __glibcxx_string_view &gt;= 201606L
which is the value for the P0254R2 paper that integrated
std::string_view with std::string, but I think just checking for the
macro being defined is clear enough.

We can also check __glibcxx_variant for the _Never_valueless_alt partial
specialization.

libstdc++-v3/ChangeLog:

	* include/bits/basic_string.h: Check __glibcxx_string_view and
	__glibcxx_variant instead of __cplusplus &gt;= 2017L.
	* include/bits/cow_string.h: Likewise.

Reviewed-by: Tomasz Kamiński &lt;tkaminsk@redhat.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Optimize string constructor</title>
<updated>2025-03-30T21:51:19+00:00</updated>
<author>
<name>Jan Hubicka</name>
<email>hubicka@ucw.cz</email>
</author>
<published>2025-03-30T21:49:49+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/gcc.git/commit/?id=9c5505a35d9d71705464f9254f55407192d31ec3'/>
<id>9c5505a35d9d71705464f9254f55407192d31ec3</id>
<content type='text'>
this patch improves code generation on string constructors.  We currently have
_M_construct which takes as a parameter two iterators (begin/end pointers to
other string) and produces new string.  This patch adds special case of
constructor where instead of begining/end pointers we readily know the string
size and also special case when we know that source is 0 terminated.  This
happens commonly when producing stirng copies. Moreover currently ipa-prop is
not able to propagate information that beg-end is known constant (copied string
size) which makes it impossible for inliner to spot the common case where
string size is known to be shorter than 15 bytes and fits in local buffer.

Finally I made new constructor inline. Because it is explicitely instantiated
without C++20 constexpr we do not produce implicit instantiation (as required
by standard) which prevents inlining, ipa-modref and any other IPA analysis to
happen.  I think we need to make many of the other functions inline, since
optimization accross string manipulation is quite important. There is PR94960
to track this issue.

Bootstrapped/regtested x86_64-linux, OK?

libstdc++-v3/ChangeLog:

	PR tree-optimization/103827
	PR tree-optimization/80331
	PR tree-optimization/87502

	* config/abi/pre/gnu.ver: Add version for _M_construct&lt;bool&gt;
	* include/bits/basic_string.h: (basic_string::_M_construct&lt;bool&gt;): Declare.
	(basic_string constructors): Use it.
	* include/bits/basic_string.tcc: (basic_string::_M_construct&lt;bool&gt;): New template.
	* src/c++11/string-inst.cc: Instantated S::_M_construct&lt;bool&gt;.

gcc/testsuite/ChangeLog:

	* g++.dg/tree-ssa/pr80331.C: New test.
	* g++.dg/tree-ssa/pr87502.C: New test.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
this patch improves code generation on string constructors.  We currently have
_M_construct which takes as a parameter two iterators (begin/end pointers to
other string) and produces new string.  This patch adds special case of
constructor where instead of begining/end pointers we readily know the string
size and also special case when we know that source is 0 terminated.  This
happens commonly when producing stirng copies. Moreover currently ipa-prop is
not able to propagate information that beg-end is known constant (copied string
size) which makes it impossible for inliner to spot the common case where
string size is known to be shorter than 15 bytes and fits in local buffer.

Finally I made new constructor inline. Because it is explicitely instantiated
without C++20 constexpr we do not produce implicit instantiation (as required
by standard) which prevents inlining, ipa-modref and any other IPA analysis to
happen.  I think we need to make many of the other functions inline, since
optimization accross string manipulation is quite important. There is PR94960
to track this issue.

Bootstrapped/regtested x86_64-linux, OK?

libstdc++-v3/ChangeLog:

	PR tree-optimization/103827
	PR tree-optimization/80331
	PR tree-optimization/87502

	* config/abi/pre/gnu.ver: Add version for _M_construct&lt;bool&gt;
	* include/bits/basic_string.h: (basic_string::_M_construct&lt;bool&gt;): Declare.
	(basic_string constructors): Use it.
	* include/bits/basic_string.tcc: (basic_string::_M_construct&lt;bool&gt;): New template.
	* src/c++11/string-inst.cc: Instantated S::_M_construct&lt;bool&gt;.

gcc/testsuite/ChangeLog:

	* g++.dg/tree-ssa/pr80331.C: New test.
	* g++.dg/tree-ssa/pr87502.C: New test.
</pre>
</div>
</content>
</entry>
</feed>
