std::messag...s::do_close(3)

πŸ“¦ version 2024.07.05, in nixpkgs unstable, opensuse-leap 16.0

πŸ’– NAME πŸ’–

okay bestie, welcome to the std::messag...s::do_close(3) page from the C++ Standard Libary manual β€” yes, that’s the manual name, spelling and all, and we’re keeping it πŸ’…

  • std::messages::close,std::messages::do_close β€” the exact dynamic duo this page is about. Periodt.

🌸 Synopsis 🌸

This whole situation is defined in the header <locale>, and here’s the signature lineup:

public:                                   (1)
void close( catalog c ) const;
protected:                                (2)
virtual void do_close( catalog c ) const;
  1. Public member function β€” it calls the protected virtual member function do_close of the most derived class. That’s the assignment, no cap.
  2. Releases the implementation-defined resources associated with an open catalog that is designated by the value c of type catalog (inherited from std::messages_base), which was obtained from open(). That’s the cleanup vibe.

πŸŽ€ Parameters πŸŽ€

  • c β€” a valid open catalog identifier, on which close() has not yet been called. So like, still valid, still open, and not already closed, bestie 🫢

πŸ¦‹ Return value πŸ¦‹

(none) β€” literally nothing comes back. It’s giving void, and honestly? iconic.

πŸ”₯ Notes πŸ”₯

  • On POSIX systems, this function call usually translates to a call to catclose().
  • In GNU libstdc++, which is implemented in terms of GNU gettext(), it does nothing. That’s right β€” it literally does nothing there 😭.

🌈 Example 🌈

This example demonstrates retrieval of messages β€” on a typical GNU/Linux system it reads from /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);
}

Possible output:

"No match" in German: Keine Übereinstimmung
"Memory exhausted" in German: Speicher erschΓΆpft

🌸 See also 🌸

mwah πŸ’‹ source/version: http://cppreference.com Β· date: 2024.06.10 Β· page: std::messag...s::do_close(3) β€” slay, bye 🫢

πŸ“¦ where this page comes from