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

<string>: char_traits specializations for "exotic" chars #5311

Open
tiagomacarios opened this issue Feb 24, 2025 · 4 comments
Open

<string>: char_traits specializations for "exotic" chars #5311

tiagomacarios opened this issue Feb 24, 2025 · 4 comments
Labels
enhancement Something can be improved

Comments

@tiagomacarios
Copy link
Member

tiagomacarios commented Feb 24, 2025

libc++ has removed the char_traits base template.

... it must be noted that the Standard only specifies specializations of char_traits for char, char8_t, char16_t, char32_t and wchar_t. However, before this patch, we would provide a base template that accepted anything, and as a result code like std::basic_string<long long> would compile but nobody knows what it really does. It basically compiles by accident.

Should the MSVC STL adopt the same changes? This would greatly help cross-platform developers. Louis also has a great point about correctness.

Xcode 16.3 release notes.

@StephanTLavavej
Copy link
Member

I've seen people using iostreams with signed char and unsigned char, but I forget whether that extended to basic_string.

We could explore doing this with an escape hatch.

@frederick-vs-ja
Copy link
Contributor

Similar to complex<NonFloatingPoint> (see #1078), although the standard wording is obscurer for char_traits. I've filed LWG-4152 for this, but it's now unclear to me what LWG will decide to do.

@AlexGuteniev
Copy link
Contributor

It might make sense to support /Zc:wchar_t--aware code even after dropping the support for the option itself, so basic_string<unsigned short> may be needed.

@StephanTLavavej StephanTLavavej added the enhancement Something can be improved label Feb 26, 2025
@StephanTLavavej
Copy link
Member

@AlexGuteniev Note that for ordinary compilations with real wchar_t, users should not see unsigned short machinery - we've been improving the library in this area. For /Zc:wchar_t-, any mentions of wchar_t will mean unsigned short.

The only code that needs to emit both wchar_t and unsigned short is our separately compiled code that has to talk to both real and fake wchar_t clients.

@StephanTLavavej StephanTLavavej changed the title <string>: char_traits specializations for "exotic" chars <string>: char_traits specializations for "exotic" chars Feb 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Something can be improved
Projects
None yet
Development

No branches or pull requests

4 participants