Skip to content

Commit 3a8f6c5

Browse files
<xlocale>: Deprecate non-Standard locale::empty() (#5197)
1 parent 3c31602 commit 3a8f6c5

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

stl/inc/xlocale

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,8 @@ public:
400400

401401
static _MRTIMP2_PURE locale __CLRCALL_PURE_OR_CDECL global(const locale&); // current locale
402402

403-
static _MRTIMP2_PURE locale __CLRCALL_PURE_OR_CDECL empty(); // empty (transparent) locale
403+
// TRANSITION, ABI: non-Standard empty() is preserved for binary compatibility
404+
_DEPRECATE_LOCALE_EMPTY static _MRTIMP2_PURE locale __CLRCALL_PURE_OR_CDECL empty(); // empty (transparent) locale
404405

405406
private:
406407
struct _Secret_locale_construct_tag {

stl/inc/yvals_core.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1517,7 +1517,17 @@ _EMIT_STL_ERROR(STL1004, "C++98 unexpected() is incompatible with C++23 unexpect
15171517
#define _CXX20_DEPRECATE_CODECVT_CHAR8_T_FACETS
15181518
#endif // ^^^ warning disabled ^^^
15191519

1520-
// next warning number: STL4048
1520+
#if !defined(_SILENCE_LOCALE_EMPTY_DEPRECATION_WARNING) && !defined(_SILENCE_ALL_MS_EXT_DEPRECATION_WARNINGS)
1521+
#define _DEPRECATE_LOCALE_EMPTY \
1522+
[[deprecated( \
1523+
"warning STL4048: locale::empty() is a non-Standard extension and will be removed in the future. A " \
1524+
"default-constructed locale can be used instead. You can define _SILENCE_LOCALE_EMPTY_DEPRECATION_WARNING or " \
1525+
"_SILENCE_ALL_MS_EXT_DEPRECATION_WARNINGS to suppress this warning.")]]
1526+
#else // ^^^ warning enabled / warning disabled vvv
1527+
#define _DEPRECATE_LOCALE_EMPTY
1528+
#endif // ^^^ warning disabled ^^^
1529+
1530+
// next warning number: STL4049
15211531

15221532
// next error number: STL1006
15231533

stl/src/locale0.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

1010
#undef _ENFORCE_ONLY_CORE_HEADERS // TRANSITION, <xfacet> should be a core header
1111

12+
#define _SILENCE_LOCALE_EMPTY_DEPRECATION_WARNING
13+
1214
#include <crtdbg.h>
1315
#include <internal_shared.h>
1416
#include <xatomic.h>

0 commit comments

Comments
 (0)