std::time_put::~time_put(3)

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

πŸ¦‹ std::time_put::~time_put(3) β€” C++ Standard Libary πŸ¦‹

okay bestie, this is the C++ Standard Libary manual page for std::time_put::~time_put β€” the destructor of the std::time_put facet. It's giving tiny page, very specific job, and we're gonna read it together. πŸ’…


✨ NAME ✨

std::time_put::~time_put β€” std::time_put::~time_put

🌸 Synopsis 🌸

Defined in header <locale>:

protected: ~time_put();

So yes, it destructs a std::time_put facet. This destructor is protected and virtual β€” the virtual part is because the base class destructor is virtual. No cap. 🫢

An object of type std::time_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::time_put and implements a public destructor. That's the whole vibe check. πŸŽ€

🧚 Example 🧚

The original says // Run this code, and here it is, bestie β€” exactly as given:

#include <iostream>
#include <locale>

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

int main()
{
    Destructible_time_put dc;
    // std::time_put<wchar_t> c; // compile error: protected destructor
}
lowkey iconic that the commented-out line is the whole protected-destructor lesson πŸ’€

made with πŸ’– by http://cppreference.com β€” version/date 2024.06.10 β€” bye bestie, go destroy some facets responsibly 🌈✨

πŸ“¦ where this page comes from