<sstream>: Change the underlying buffer of basic_stringbuf to basic_string
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 11.1k
- Forks
- 1.7k
- Avg merge
- 4d 15h
- Merged PRs (30d)
- 22
Description
See: https://github.com/microsoft/STL/pull/919#issuecomment-650688421
The underlying buffer of basic_stringbuf is simply an array, which makes implementing P0408R7 hard.
When there's an rvalue of basic_string received, we cannot simply replace the current buffer with the string buffer:
basic_stringuses SSO (small string optimization). When it is in small mode, the string should be copied to the current buffer;- In readonly mode,
basic_stringbufdoesn't recognize the reserved space of the string, which means we should copy the string non-conditionally.
When we want the basic_string from an rvalue of basic_stringbuf, we cannot simply construct a basic_string from the current buffer:
- The current buffer is not zero-terminated. When the buffer is already full, we should copy the buffer to a
basic_string; - It loses SSO, because
basic_stringbufdoesn't uses SSO.
We could see that the current implementation will cause a lot of copying. I think it should be fixed in vNext.
vNext note: Resolving this issue will require breaking binary compatibility. We won't be able to accept pull requests for this issue until the vNext branch is available. See #169 for more information.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the basic_stringbuf implementation and the linked P0408R7 discussion. Review how rvalue basic_string and basic_stringbuf cases interact with SSO, termination, reserved space, and readonly mode. A contribution cannot be accepted until the vNext branch is available, and completion would require a design that avoids the described copying while preserving compatibility requirements.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- tooling
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 20/100