Unify locale helpers with if constexpr by StephanTLavavej · Pull Request #5923 · microsoft/STL (original) (raw)
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 andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Conversation1 Commits15 Checks45 Files changed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
[ Show hidden characters]({{ revealButtonHref }})
Works towards #189.
Commits
- Drop
__CRTDECLon internal header-only functions.- Replaced:
__CRTDECL (_LStr(coll|xfrm)|_Makloc(byte|chr|str)|_Getloctxt)=>$1 - These functions aren't dllexported or address-taken, so their calling convention doesn't matter. (
<vcruntime.h>defines__CRTDECLto be__CLRCALL_PURE_OR_CDECL.)
- Replaced:
- Unify with
if constexpr, part 1:_LStrcoll() - Unify with
if constexpr, part 2:_LStrxfrm() - Unify with
if constexpr, part 3:_Maklocbyte,_Maklocchr,_Maklocstr - Fix bogus SAL annotations on
_Strxfrm(),_Wcsxfrm(), and_LStrxfrm(), following : regex_traits::transform_primary should yield primary sort keys appropriate for the imbued locale #5444. - Fix comment:
_XStrxfrm(no such thing) =>_LStrxfrm _Maklocbyte,_Maklocchr,_Maklocstr: Guardunsigned shortwith#ifdef _CRTBLD.- This follows
_LStrcolland_LStrxfrm, changed by : Repair std::collate #5361. - Followup to the very old STL: When wchar_t is a real type, users shouldn't see unsigned short machinery #216. This leaves
codecvt<unsigned short, char, mbstate_t>andctype<unsigned short>as the only exceptions; I currently don't understand what's going on with them.
- This follows
- Pass an explicit template arg to
_Maklocchrand_Maklocstrinstead of a typed null pointer.- This is fine because it can't be deduced now. These are header-only (and aren't
extern "C") and their signatures are changing, so we don't need to rename them.
- This is fine because it can't be deduced now. These are header-only (and aren't
- Unify
wchar_tandunsigned short, part 1: Prepare_Maklocstr - Unify
wchar_tandunsigned short, part 2: Prepare_Maklocbyte,_Maklocchr - Unify
wchar_tandunsigned short, part 3: Extract_Is_wchar_or_crtbld_ushort.remove_cv_t<_Elem>is currently unnecessary, but it makes me feel better to have type traits that behave like the primary type categories.
_Maklocstr: Remove dead_Count -= _Bytes._Countis unused at this point (and there's no outer loop).
_Maklocstr: Improve variable scoping, part 1._Countcan be scoped to the for-loop._Count1can be const._Wcharsand_Ptr1can be initialized when defined, instead of assigned at the beginning of the for-loop.
_Maklocstr: Improve variable scoping, part 2._Bytesdoesn't communicate information across loops or loop iterations. It's always assigned to in the loop body, then read from at the end of the iteration. Making it a const local in each loop iteration is significantly clearer.
- Guard
locale::_Locimp::_Makeushloc()with#ifdef _CRTBLD.- Users with real
wchar_tshould never see this.
- Users with real
__CRTDECL (_LStr(coll|xfrm)|_Makloc(byte|chr|str)|_Getloctxt) => $1
These functions aren't dllexported or address-taken, so their calling convention doesn't matter.
…rm()`, following GH 5444.
…h #ifdef _CRTBLD.
This follows _LStrcoll and _LStrxfrm, changed by GH 5361.
…d of a typed null pointer.
This is fine because it can't be deduced now.
These are header-only (and aren't extern "C") and their signatures are changing, so we don't need to rename them.
…rtbld_ushort`.
remove_cv_t<_Elem> is currently unnecessary, but it makes me feel better to have type traits that behave like the primary type categories.
_Count is unused at this point (and there's no outer loop).
_Count can be scoped to the for-loop.
_Count1 can be const.
_Wchars and _Ptr1 can be initialized when defined, instead of assigned at the beginning of the for-loop.
_Bytes doesn't communicate information across loops or loop iterations. It's always assigned to in the loop body, then read from at the end of the iteration. Making it a const local in each loop iteration is significantly clearer.
Users with real wchar_t should never see this.
I'm mirroring this to the MSVC-internal repo - please notify me if any further changes are pushed.