std::moneyp...~moneypunct(3)

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

πŸ’… std::moneyp...~moneypunct(3) πŸ’…

okay bestie, welcome to the C++ Standard Libary manual page for std::moneypunct::~moneypunct β€” yes, the destructor. It’s giving tiny cleanup era, and honestly the vibes are immaculate. πŸŽ€


✨ NAME ✨

  • std::moneypunct::~moneypunct β€” std::moneypunct::~moneypunct (yes, it literally says the name twice, and that’s iconic)

🌸 Synopsis 🌸

Defined in header <locale> β€” that’s home base, bestie.

protected: ~moneypunct();

This destructor literally destructs a std::moneypunct facet. It’s protected and virtual (because the base class destructor is virtual, so it inherits that energy).

An object of type std::moneypunct, 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::moneypunct and implements a public destructor. Periodt. πŸ’…


πŸ’– Example πŸ’–

// Run this code

#include <iostream>
#include <locale>

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

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

The way this example ate: Destructible_moneypunct derives from std::moneypunct<wchar_t>, gives itself a constructor with std::size_t refs = 0 forwarding to moneypunct(refs), and leaves the implicit destructor public. Meanwhile the commented-out std::moneypunct<wchar_t> c; is a compile error because the destructor is protected. No cap. πŸ¦‹


okay that’s the page, bestie πŸ’– source is http://cppreference.com, version/date is 2024.06.10, and we made it through std::moneyp...~moneypunct(3) together. slay. πŸŽ€

πŸ“¦ where this page comes from