Within the Standard C++ Library iostreams, locale is a class. Class locale is used for two distinct purposes:
The formatting layer of iostreams uses locale facilities for numeric formatting and character classification.
The transport layer uses locale facilities for code conversion.
In the standard iostream classes, the formatting (stream) layer uses only the ctype, num_put, and num_get facets, while the transport (stream buffer) layer uses only the codecvt facet. For more information on locales and facets, see Chapter 3 and the sections of the Class Reference devoted to the locale class and the various facets.
Each layer contains its own locale, so the code conversion facility can be changed independent of numeric formatting. We simply change the locale associated with a stream buffer without altering the locale contained by the stream using that buffer. On the other hand, changing a stream's locale also changes the locale contained by the associated stream buffer.
The base class for all streams, ios_base, contains a locale. This locale can be accessed with the getloc() function and changed with the imbue() function. Similarly, the basic_streambuf class also contains a locale and it has a getloc() function and pubimbue() function. A stream buffer has a protected imbue() function. In both cases the imbue() function is virtual in order to allow derived classes to change how localization is implemented.
OEM Edition, ©Copyright 1999, Rogue Wave Software, Inc.
Contact Rogue Wave about documentation or support issues.