std::locale::combine

来自cppreference.com
< cpp‎ | locale‎ | locale
定义于头文件 <locale>
template< class Facet >
locale combine( const locale& other ) const;

构造 locale 对象,结果为 *this 的副本,除了 Facet 类型平面复制自 other

返回值

新的无名 locale 。

异常

other 不实装 Facet 则为 std::runtime_error

示例

#include <iostream>
#include <locale>
 
int main()
{
    const double 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';
}

输出:

"C" locale: 1000.25
"C" locale with en_US numpunct: 1,000.25

参阅

构造新的 locale
(公开成员函数)