https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112925
--- Comment #8 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Nathan Myers <[email protected]>: https://gcc.gnu.org/g:2b369385ea28b3aceb7cd28a4c9a96a8e2609031 commit r17-5909-g2b369385ea28b3aceb7cd28a4c9a96a8e2609031 Author: Nathan Myers <[email protected]> Date: Fri Oct 23 16:22:53 2026 -0400 libstdc++: improve string construction from streambuf [PR112925] Changes in v2: - When constructing from a streambuf iterator range, ensure its sentinel is another streambuf iterator, or default_sentinel. - Add #pragma diagnostic push for "if constexpr" in c++11. - Add c++11 test for construction from raw iterators. - Add test with a sentinel in place of default-ctor'd iterator. - Add test with range pipeline. - Remove spurious 'constexpr' in test. Constructing a string from a streambuf iterator pair or range has been found to be 3x faster using the streambuf member `sgetn`. This is the minimal implementation as outlined in [PR112925]. Future improvements might include doing the same optimization when appending, and preallocating when the final size can be known. libstdc++-v3/ChangeLog: PR libstdc++/112925 * include/bits/basic_string.h (basic_string range ctor): Special-case ranges of streambuf iterators. * include/bits/basic_string.tcc (_M_construct): Special-case streambuf iterators. These always consume the whole stream. * testsuite/21_strings/basic_string/cons/char/from_sbufiter.cc: New test, construction from two istreambuf_iterators. * testsuite/21_strings/basic_string/cons/from_range2.cc: New tests, construction from ranges.
