C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Forbid optimisations on std::basic_string implementations.

From: Ben Crowhurst <ben.crowhurst_at_[hidden]>
Date: Mon, 18 Aug 2025 14:15:59 +0000
On Monday, August 18th, 2025 at 12:28 PM, Sebastian Wittmeier via Std-Proposals <std-proposals_at_[hidden]> wrote:

> You are suggesting a new string class, which allows more optimizations.
>

I'm not suggesting additional optimisations; the behaviour of std::basic_string when interacting with other STL elements should be well-defined, regardless of string length.

This is currently left as an implementation detail.

> Could you go into detail, what kind of optimizations you think of (example), and why they are not possible and not implemented in the current std::basic_string and why they are more allowed in the new class.
>
> Perhaps beside allowing something to implementations, there is also a use case for a different string-like class or a different interface.
>
>
> > -----Ursprüngliche Nachricht-----
> > Von: Ben Crowhurst via Std-Proposals <std-proposals_at_[hidden]>
> > Gesendet: Mo 18.08.2025 12:33
> > Betreff: [std-proposals] Forbid optimisations on std::basic_string implementations.
> > An: std-proposals_at_[hidden];
> > CC: Ben Crowhurst <ben.crowhurst_at_[hidden]>;
> > body { font-family: monospace; }
> >
> > There is a history of STL implementations introducing string optimisations, for example, copy-on-write in GCC (<=4), adoption of small string optimisation (SSO) - with varying details across GCC, Clang, and MSVC.
> >
> > Focusing on SSO, using std::string, along with std::string_view and move semantics, introduces a frustrating folly.
> >
> > The name std::basic_string implies a basic implementation, and many assume it is nothing more than a wrapper around a C-style character pointer with bounds checking.
> >
> > Could we discuss introducing an alternative string implementation (std::buffered_string, std::small_string) to the standard that allows optimisations without specifying the core details? Hopefully, this will add some clarity to the end-user.
> >
> > Thank you for your time.
> >
> > Regards,
> > Ben Crowhurst
> >
> > --
> > Std-Proposals mailing list
> > Std-Proposals_at_[hidden]
> > https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
> >

Received on 2025-08-18 14:16:08