名前空間
変種
操作

std::messages<CharT>::close, std::messages<CharT>::do_close

提供: cppreference.com
< cpp‎ | locale‎ | messages
 
 
 
 
ヘッダ <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 から読み込みます。

#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

[編集] 関連項目