Skip to content

Commit

Permalink
Allow locale{nullptr} to compile (#4245)
Browse files Browse the repository at this point in the history
  • Loading branch information
StephanTLavavej authored Dec 7, 2023
1 parent cff27f7 commit cf1313c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
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

0 comments on commit cf1313c

Please sign in to comment.