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

Allow locale{nullptr} to compile #4245

Merged
merged 1 commit into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions stl/inc/xlocale
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ public:
_Newimp->_Addfac(_Facptr, _Facet::id);
_Newimp->_Catmask = none;
_Newimp->_Name = "*";
return locale{_Newimp};
return locale{_Secret_locale_construct_tag{}, _Newimp};
}

template <class _Facet>
Expand Down Expand Up @@ -391,7 +391,11 @@ public:
static _MRTIMP2_PURE locale __CLRCALL_PURE_OR_CDECL empty(); // empty (transparent) locale

private:
locale(_Locimp* _Ptrimp) : _Ptr(_Ptrimp) {}
struct _Secret_locale_construct_tag {
explicit _Secret_locale_construct_tag() = default;
};

explicit locale(_Secret_locale_construct_tag, _Locimp* _Ptrimp) : _Ptr(_Ptrimp) {}

static _MRTIMP2_PURE _Locimp* __CLRCALL_PURE_OR_CDECL _Init(bool _Do_incref = false); // initialize locale
static _MRTIMP2_PURE _Locimp* __CLRCALL_PURE_OR_CDECL _Getgloballocale();
Expand Down
4 changes: 2 additions & 2 deletions stl/src/locale0.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ _MRTIMP2_PURE const locale& __CLRCALL_PURE_OR_CDECL locale::classic() { // get r

_MRTIMP2_PURE locale __CLRCALL_PURE_OR_CDECL locale::empty() { // make empty transparent locale
_Init();
return locale{_Locimp::_New_Locimp(true)};
return locale{_Secret_locale_construct_tag{}, _Locimp::_New_Locimp(true)};
}

_MRTIMP2_PURE locale::_Locimp* __CLRCALL_PURE_OR_CDECL locale::_Init(bool _Do_incref) { // setup global and "C" locales
Expand All @@ -176,7 +176,7 @@ _MRTIMP2_PURE locale::_Locimp* __CLRCALL_PURE_OR_CDECL locale::_Init(bool _Do_in

// set classic to match
ptr->_Incref();
::new (&classic_locale) locale{ptr};
::new (&classic_locale) locale{_Secret_locale_construct_tag{}, ptr};
#if defined(_M_CEE_PURE)
locale::_Locimp::_Clocptr = ptr;
#else // ^^^ defined(_M_CEE_PURE) / !defined(_M_CEE_PURE) vvv
Expand Down