std::money_get::~money_get(3)
πΈ NAME πΈ
std::money_get::~money_get β std::money_get::~money_get
okay so this page is std::money_get::~money_get(3), and it lives in the C++ Standard Libary manual (yep, that spelling is in the header, bestie β we are not touching it π
). It's giving βtiny destructor page with serious access-control energy.β π
β¨ Synopsis β¨
- Defined in header
<locale>
protected: ~money_get();
This destructor is protected and virtual β the virtual part is due to base class destructor being virtual, iykyk. It destructs a std::money_get facet π§.
So here's the vibe: an object of type std::money_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::money_get and implements a public destructor. That's the whole rule, fr fr. π«Ά
π Example π
Run this code, bestie:
// Run this code
#include <iostream>
#include <locale>
struct Destructible_money_get : public std::money_get<wchar_t>
{
Destructible_money_get(std::size_t refs = 0) : money_get(refs) {}
// note: the implicit destructor is public
};
int main()
{
Destructible_money_get dc;
// std::money_get<wchar_t> c; // compile error: protected destructor
}
Not me leaving that // compile error: protected destructor comment right there π It's literally the plot twist: protected destructor says βbestie, no π
.β
that's the whole vibe β signing off from http://cppreference.com, version 2024.06.10, on this very std::money_get::~money_get(3) page π«Άβ¨π
π¦ 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