std::messages::~messages(3)

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

okay bestie, this manual page is std::messages::~messages(3), and the manual name is C++ Standard Libary (yes, exactly like that on the page, no cap 😭). It's giving destructor lore, and we're gonna get through it together. πŸ’–

πŸŽ€ NAME πŸŽ€

std::messages::~messages β€” literally std::messages::~messages, the destructor page, periodt. ✨

🌸 Synopsis 🌸

Defined in header <locale> 🫢

protected: ~messages();

So here's the tea: it destructs a std::messages facet. This destructor is protected and virtual (due to base class destructor being virtual, iykyk πŸ’…).

An object of type std::messages, like most facets, can only be destroyed when the last std::locale object that implements this facet goes out of scope β€” or if a user-defined class is derived from std::messages and implements a public destructor. That's the whole rule, no cap. πŸ¦‹

🧚 Example 🧚

Run this code, bestie:

#include <iostream>
#include <locale>

struct Destructible_messages : public std::messages<wchar_t>
{
    Destructible_messages(std::size_t refs = 0) : messages(refs) {}
    // note: the implicit destructor is public
};

int main()
{
    Destructible_messages dc;
    // std::messages<wchar_t> c; // compile error: protected destructor
}

Not the comment literally saying // compile error: protected destructor 😭 β€” respect the protected destructor, okay? πŸ™ˆ


okay that's the whole page! Source/version/date sign-off: http://cppreference.com, 2024.06.10, and the page is std::messages::~messages(3) β€” mwah, bye bestie πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from