std::time_get::~time_get(3)
π NAME π
std::time_get::~time_get β literally std::time_get::~time_get, bestie. This is the destructor page from the C++ Standard Libary manual, and itβs giving βtiny but important facet cleanupβ energy. π
β¨ Synopsis β¨
Defined in header <locale>:
protected: ~time_get();
Okay so this destructs a std::time_get facet. Itβs protected and virtual (due to the base class destructor being virtual). And because of that protected-ness, an object of type std::time_get, 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_get and implements a public destructor. No cap, thatβs the whole vibe. π¦
Heads up: the destructor is protected, so that last part is the loophole the example is using β a derived class with a public destructor. π₯
πΈ Example πΈ
// Run this code
#include <iostream>
#include <locale>
struct Destructible_time_get : public std::time_get<wchar_t>
{
Destructible_time_get(std::size_t refs = 0) : time_get(refs) {}
// note: the implicit destructor is public
};
int main()
{
Destructible_time_get dc;
// std::time_get<wchar_t> c; // compile error: protected destructor
}
Look at that little Destructible_time_get slaying with a public implicit destructor, while std::time_get<wchar_t> c; gets dunked on by a compile error because the destructor is protected. Iconic. π
Source/version check: this page comes from http://cppreference.com, dated 2024.06.10, with the manual tag std::time_get::~time_get(3). Bye bestie, go destroy your facets responsibly! π«Άβ¨
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms