std::basic_ios<CharT,Traits>::imbue - cppreference.com (original) (raw)

C++

Compiler support
Freestanding and hosted
Language
Standard library
Standard library headers
Named requirements
Feature test macros (C++20)
Language support library
Concepts library (C++20)
Diagnostics library
Memory management library
Metaprogramming library (C++11)
General utilities library
Containers library
Iterators library
Ranges library (C++20)
Algorithms library
Strings library
Text processing library
Numerics library
Date and time library
Input/output library
Filesystem library (C++17)
Concurrency support library (C++11)
Execution control library (C++26)
Technical specifications
Symbols index
External libraries

[edit]

Input/output library

I/O manipulators
Print functions (C++23)
C-style I/O
Buffers
basic_streambuf
basic_filebuf
basic_stringbuf
basic_spanbuf(C++23)
strstreambuf(C++98/26*)
basic_syncbuf(C++20)
Streams
Abstractions
ios_base
basic_ios
basic_istream
basic_ostream
basic_iostream
File I/O
basic_ifstream
basic_ofstream
basic_fstream
String I/O
basic_istringstream
basic_ostringstream
basic_stringstream
Array I/O
basic_ispanstream(C++23)
basic_ospanstream(C++23)
basic_spanstream(C++23)
istrstream(C++98/26*)
ostrstream(C++98/26*)
strstream(C++98/26*)
Synchronized Output
basic_osyncstream(C++20)
Types
streamoff
streamsize
fpos
Error category interface
iostream_category(C++11)
io_errc(C++11)

[edit]

std::basic_ios

Member functions
basic_ios::basic_ios
basic_ios::~basic_ios
State functions
basic_ios::good
basic_ios::eof
basic_ios::fail
basic_ios::bad
basic_ios::operator!
basic_ios::operator bool
basic_ios::rdstate
basic_ios::setstate
basic_ios::clear
Formatting
basic_ios::copyfmt
basic_ios::fill
Miscellaneous
basic_ios::exceptions
basic_ios::imbue
basic_ios::rdbuf
basic_ios::tie
basic_ios::narrow
basic_ios::widen
Protected member functions
basic_ios::init
basic_ios::move(C++11)
basic_ios::swap(C++11)
basic_ios::set_rdbuf(C++11)

[edit]

| std::locale imbue( const std::locale& loc ); | | | | ---------------------------------------------------------------------------------------------------- | | |

Replaces the current locale. Effectively calls ios_base::imbue(loc) and if there is an associated stream buffer (rdbuf() != 0), then calls rdbuf()->pubimbue(loc).

Contents

[edit] Parameters

loc - the new locale

[edit] Return value

The previous locale, as returned by ios_base::imbue(loc).

[edit] Exceptions

May throw implementation-defined exceptions.

[edit] Example

Run this code

#include #include #include   int main() { std::istringstream iss; iss.imbue(std::locale("en_US.UTF8"));   std::cout << "Current locale: " << iss.getloc().name() << '\n';   iss.imbue(std::locale()); std::cout << "Global locale : " << iss.getloc().name() << '\n'; }

Output:

Current locale: en_US.UTF8 Global locale : C