std::any::~any

Destroys the contained object, if any, as if by a call to reset().

# Declarations

~any();

(since C++17)

# Example

#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()...");
}

# See also