std::messages<CharT>::close, std::messages<CharT>::do_close
提供: cppreference.com
<tbody>
</tbody>
| ヘッダ <locale> で定義
|
||
public: void close( catalog c ) const; |
(1) | |
protected: virtual void do_close( catalog c ) const; |
(2) | |
1) public メンバ関数。 最も派生したクラスの protected virtual メンバ関数
do_close を呼びます。2) open() から取得した (std::messages_base から継承した)
catalog 型の値 c によって指定される開いたカタログと紐付いている、処理系定義のリソースを解放します。引数
| c | - | close() がまだ呼ばれていない、有効な開いたカタログの識別子
|
戻り値
(なし)
ノート
POSIX システムでは、この関数は通常 catclose() の呼び出しに変換されます。 GNU gettext() によって実装されている GNU libstdc++ では、何もしません。
例
以下の例はメッセージの取得をデモンストレーションします。 一般的な GNU/Linux システムでは /usr/share/locale/de/LC_MESSAGES/sed.mo から読み込みます。
Run this code
#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