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

<xlocale>: locale::empty is non-Standard #5184

Open
cpplearner opened this issue Dec 11, 2024 · 2 comments
Open

<xlocale>: locale::empty is non-Standard #5184

cpplearner opened this issue Dec 11, 2024 · 2 comments
Labels
decision needed We need to choose something before working on this enhancement Something can be improved

Comments

@cpplearner
Copy link
Contributor

cpplearner commented Dec 11, 2024

The std::locale class provides a member empty, which is not part of the standard.

static _MRTIMP2_PURE locale __CLRCALL_PURE_OR_CDECL empty(); // empty (transparent) locale

This member is documented on https://learn.microsoft.com/en-us/cpp/standard-library/locale-class?view=msvc-170:

In this implementation, you can also call the static member function:

static locale empty();

to construct a locale object that has no facets. It's also a transparent locale. If the template functions has_facet and use_facet can't find the requested facet in a transparent locale, they consult first the global locale and then, if that is transparent, the classic locale. So, you can write:

cout.imbue(locale::empty());

Subsequent insertions to cout are mediated by the current state of the global locale.

It seems that this member is used by a few projects to read UTF-8 files, possibly (mis)guided by https://stackoverflow.com/a/10607146/4672588.

Is there any interest to deprecate and eventually remove this non-Standard extension?

@frederick-vs-ja
Copy link
Contributor

I'd like to directly remove the extension, but at this moment it should be preserved in #ifdef _CRTBLD.

In #3088 the locale::c_str extension was effectively removed. It seems also doable to some _Uglify the function name.

CC @TylerMSFT.

@CaseyCarter CaseyCarter added enhancement Something can be improved decision needed We need to choose something before working on this labels Dec 18, 2024
@CaseyCarter
Copy link
Member

If there's usage in the wild, we'll want to deprecate or remove-with-escape-hatch rather than simply hide it in #ifdef _CRTBLD.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
decision needed We need to choose something before working on this enhancement Something can be improved
Projects
None yet
Development

No branches or pull requests

3 participants