std::messages<CharT>::close, std::messages<CharT>::do_close
From cppreference.com
| ヘッダー <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