Skip to content

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

Description

@cpplearner

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?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementSomething can be improvedfixedSomething works now, yay!

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions