std::num_put::~num_put(3)

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

πŸ’… std::num_put::~num_put(3) πŸ’…

okay bestie, welcome to the C++ Standard Libary manual β€” yes, that's the manual name, typo and all β€” and today's page is std::num_put::~num_put(3). It's giving tiny destructor lore, and we're gonna read it together. 🫢

✨ NAME ✨

  • std::num_put::~num_put β€” std::num_put::~num_put

🌸 Synopsis 🌸

okay so first thing: it's defined in header <locale>. The signature drop is:

protected: ~num_put();

This bad boy destructs a std::num_put facet. The destructor is protected and virtual β€” and the virtual part is due to base class destructor being virtual. An object of type std::num_put, 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::num_put and implements a public destructor. periodt. πŸ’…

πŸŽ€ Example πŸŽ€

run this code, bestie:

// Run this code

#include <iostream>
#include <locale>

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

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

mwah πŸ’‹ β€” this page is from http://cppreference.com, dated 2024.06.10, and it's serving std::num_put::~num_put(3) realness. 🫢✨

πŸ“¦ where this page comes from