std::use_facet
来自cppreference.com
                    
                                        
                    
                    
                                                            
                    |   定义于头文件  <locale>
  | 
||
|   template< class Facet > const Facet& use_facet( const std::locale& loc );  | 
||
获得到 loc 所实装的平面的引用。
参数
| loc | - | 要查询的 locale 对象 | 
返回值
返回到平面的引用,只要存在任何 std::locale 对象实装 Facet ,则此函数所返回的引用就合法。
异常
若 std::has_facet<Facet>(loc) == false 则为 std::bad_cast 。
示例
显示用户偏好的本地环境所用的 3 字母金额名
运行此代码
#include <iostream> #include <locale> int main() { std::locale loc = std::locale(""); // 用户偏好的本地环境 std::cout << "Your currency string is " << std::use_facet<std::moneypunct<char, true>>(loc).curr_symbol() << '\n'; }
输出:
Your currency string is USD
参阅
|   用以封装文化差异的多态刻面的集合  (类)  | |
|   检查本地环境是否实现特定的刻面  (函数模板)  |