Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it by design that <string_view> provides most contents of <string>? #4625

Closed
frederick-vs-ja opened this issue Apr 24, 2024 · 1 comment · Fixed by #4633
Closed

Is it by design that <string_view> provides most contents of <string>? #4625

frederick-vs-ja opened this issue Apr 24, 2024 · 1 comment · Fixed by #4633
Labels
fixed Something works now, yay! throughput Must compile faster

Comments

@frederick-vs-ja
Copy link
Contributor

frederick-vs-ja commented Apr 24, 2024

MSVC STL's <string_view> currently directly includes <xstring>, which provides most contents of <string>.

I think it's OK for <string> to include <string_view> (since C++17). But when one only includes <string_view>, perhaps it's sometimes expected that no mechanism of dynamic allocation is made available.

If the status quo is not by design, I think we may extract the mechanisms of char_traits into a new internal header and make <string_view> slimmer.

@frederick-vs-ja frederick-vs-ja added the question Further information is requested label Apr 24, 2024
@StephanTLavavej StephanTLavavej added throughput Must compile faster and removed question Further information is requested labels Apr 24, 2024
@StephanTLavavej
Copy link
Member

We talked about this at the weekly maintainer meeting and we don't remember why it was done this way. Extracting both char_traits and basic_string_view into an internal header (above <xstring>, e.g. <__msvc_string_view.hpp>) would allow <string_view> to avoid dragging in basic_string. We don't expect that extracting char_traits by itself would be useful, as any usage of char_traits is virtually certain to need either basic_string_view or basic_string.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fixed Something works now, yay! throughput Must compile faster
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants