public member function
std::ios::imbue
<ios>
locale imbue ( const locale& loc );
Imbue locale
Associates
loc to both the stream and its associated stream buffer (if any) as the new locale object to be used with locale-sensitive operations.
All callback functions registered with register_callback with
imbue_event as its first parameter are called.
In fact, this member function calls its inherited homonym
ios_base::imbue(loc), and if the stream is associated with a stream buffer, also calls
rdbuf()->pubimbue(loc).
Parameters
- loc
- locale object to be imbued as the new locale for the stream.
Return value
The
locale object associated with the stream before the call.
Example
1 2 3 4 5 6 7 8 9 10 11 12
|
// imbue example
#include <iostream>
#include <locale>
using namespace std;
int main()
{
locale mylocale(""); // Construct locale object with the user's default preferences
cout.imbue( mylocale ); // Imbue that locale
cout << (double) 3.14159 << endl;
return 0;
}
|
This code writes a floating point number using the user's prefered locale. For example, in a system configured with a Spanish locale as default, this should write the number using a comma decimal separator:
See also
- ios_base::imbue
- Imbue locale (public member function)
- ios_base::getloc
- Get current locale (public member function)