std::messages<CharT>:: close, std::messages<CharT>:: do_close
From cppreference.net
C++
Text processing library
| 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 | |||||||||||||||||||||||||
|
|||||||||||||||||||||||||
Localization library
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
std::messages
| Member functions | ||||
|
messages::close
messages::do_close
|
|
定义于头文件
<locale>
|
||
|
public
:
void close ( catalog c ) const ; |
(1) | |
|
protected
:
virtual void do_close ( catalog c ) const ; |
(2) | |
1)
公开成员函数,调用最派生类的受保护虚成员函数
do_close
。
目录 |
参数
| c | - |
一个有效的已打开目录标识符,尚未对其调用
close()
|
返回值
(无)
注释
在POSIX系统上,此函数调用通常转换为对
catclose()
的调用。在基于GNU
gettext()
实现的GNU libstdc++中,该函数不执行任何操作。
示例
以下示例演示了消息检索功能:在典型的 GNU/Linux 系统上,该程序会从
/usr/share/locale/de/LC_MESSAGES/sed.mo
读取消息。
运行此代码
#include <iostream> #include <locale> int main() { std::locale loc("de_DE.utf8"); std::cout.imbue(loc); auto& facet = std::use_facet<std::messages<char>>(loc); auto cat = facet.open("sed", loc); if (cat < 0) std::cout << "Could not open german \"sed\" message catalog\n"; else std::cout << "\"No match\" in German: " << facet.get(cat, 0, 0, "No match") << '\n' << "\"Memory exhausted\" in German: " << facet.get(cat, 0, 0, "Memory exhausted") << '\n'; facet.close(cat); }
可能的输出:
"No match" in German: Keine Übereinstimmung "Memory exhausted" in German: Speicher erschöpft