<locale>
: Repair std::collate<unsigned short>
#5361
+136
−62
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This repairs
collate<unsigned short>
by adding two missingunsigned short
specializations for_LStrcoll
and_LStrxfrm
whenwchar_t
is a native type. Fixes #5236.There are similar specializations for a few functions in
<xlocale>
. I guess_LStrcoll
and_LStrxfrm
were missed because they are located in a different header.Since
collate
is the only user of these functions, I also moved them from<xlocinfo>
to<locale>
just abovecollate
.As for why this also fixes
collate<wchar_t>
=collate<unsigned short>
under non-nativewchar_t
when linking to the DLL, this is because the the locale facets are constructed in the DLL here:STL/stl/src/wlocale.cpp
Lines 58 to 88 in f2a2933
Thus,
collate
's virtual functions originate from the DLL as well. These virtual functions call_LStrcoll
and_LStrxfrm
, but the specializations forunsigned short
were missing since the DLL is built with nativewchar_t
.The setup of the new test is a bit wild, but it's the best I could come up with:
wchar_t
, we have to makecollate<unsigned short>
well-defined by setting_ENFORCE_LOCALE_SPECIALIZATIONS
to0
.collate::transform()
tests when there is IDL mismatch between TU and linked DLL.collate<unsigned short>::id
. I tried defining__FORCE_INSTANCE
instead (which is used to the same effect during the DLL build), but this results in several warnings-turned-errors in other facets. So it's either this or suppressing more warnings in STL headers.