Namespaces
Variants

std::any:: ~any

From cppreference.net
Utilities library
~any ( ) ;
(seit C++17)

Zerstört das enthaltene Objekt, falls vorhanden, wie durch einen Aufruf von reset() .

Beispiel

#include <any>
#include <cstdio>
struct X
{
    X() { std::puts("X::X()"); }
    X(const X&) { std::puts("X::X(const X&)"); }
    ~X() { std::puts("X::~X()"); }
};
int main()
{
    std::any a{X{}};
    std::puts("Leaving main()...");
}

Ausgabe:

X::X()
X::X(const X&)
X::~X()
Leaving main()...
X::~X()

Siehe auch

zerstört enthaltenes Objekt
(öffentliche Elementfunktion)