Skip to content

Commit cf1313c

Browse files
Allow locale{nullptr} to compile (#4245)
1 parent cff27f7 commit cf1313c

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

stl/inc/xlocale

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ public:
226226
_Newimp->_Addfac(_Facptr, _Facet::id);
227227
_Newimp->_Catmask = none;
228228
_Newimp->_Name = "*";
229-
return locale{_Newimp};
229+
return locale{_Secret_locale_construct_tag{}, _Newimp};
230230
}
231231

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

393393
private:
394-
locale(_Locimp* _Ptrimp) : _Ptr(_Ptrimp) {}
394+
struct _Secret_locale_construct_tag {
395+
explicit _Secret_locale_construct_tag() = default;
396+
};
397+
398+
explicit locale(_Secret_locale_construct_tag, _Locimp* _Ptrimp) : _Ptr(_Ptrimp) {}
395399

396400
static _MRTIMP2_PURE _Locimp* __CLRCALL_PURE_OR_CDECL _Init(bool _Do_incref = false); // initialize locale
397401
static _MRTIMP2_PURE _Locimp* __CLRCALL_PURE_OR_CDECL _Getgloballocale();

stl/src/locale0.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ _MRTIMP2_PURE const locale& __CLRCALL_PURE_OR_CDECL locale::classic() { // get r
159159

160160
_MRTIMP2_PURE locale __CLRCALL_PURE_OR_CDECL locale::empty() { // make empty transparent locale
161161
_Init();
162-
return locale{_Locimp::_New_Locimp(true)};
162+
return locale{_Secret_locale_construct_tag{}, _Locimp::_New_Locimp(true)};
163163
}
164164

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

177177
// set classic to match
178178
ptr->_Incref();
179-
::new (&classic_locale) locale{ptr};
179+
::new (&classic_locale) locale{_Secret_locale_construct_tag{}, ptr};
180180
#if defined(_M_CEE_PURE)
181181
locale::_Locimp::_Clocptr = ptr;
182182
#else // ^^^ defined(_M_CEE_PURE) / !defined(_M_CEE_PURE) vvv

0 commit comments

Comments
 (0)