| Localization library | |||||||||||||||||||||||||
| Regular expressions library(C++11) | |||||||||||||||||||||||||
| Formatting library(C++20) | |||||||||||||||||||||||||
| Null-terminated sequence utilities | |||||||||||||||||||||||||
| Byte strings | |||||||||||||||||||||||||
| Multibyte strings | |||||||||||||||||||||||||
| Wide strings | |||||||||||||||||||||||||
| Primitive numeric conversions | |||||||||||||||||||||||||
| |||||||||||||||||||||||||
| Text encoding identifications | |||||||||||||||||||||||||
| |||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Member types | ||||
| Member functions | ||||
locale::combine | ||||
(C++26) | ||||
(until C++20) | ||||
| Static member functions | ||||
template<class Facet> locale combine(const locale& other)const; | ||
Constructs a locale object which is a copy of*this except for the facet of typeFacet, which is copied fromother.
The program is ill-formed if Facet is not afacet or it is a volatile-qualified facet.
Contents |
The new, nameless, locale.
std::runtime_error ifother does not implementFacet.
#include <iostream>#include <locale> int main(){constdouble number=1000.25;std::cout<<"\"C\" locale: "<< number<<'\n';std::locale loc=std::locale() .combine<std::numpunct<char>>(std::locale("en_US.UTF8"));std::cout.imbue(loc);std::cout<<"\"C\" locale with en_US numpunct: "<< number<<'\n';}
Output:
"C" locale: 1000.25"C" locale with en_US numpunct: 1,000.25
The following behavior-changing defect reports were applied retroactively to previously published C++ standards.
| DR | Applied to | Behavior as published | Correct behavior |
|---|---|---|---|
| LWG 14 | C++98 | locale::combine was non-const | made const |
| LWG 436 | C++98 | it was unclear whetherFacet can be cv-qualified | it can be const-qualified, but not volatile-qualified |
| constructs a new locale (public member function)[edit] |