Namespaces
Variants

std::any::~any

From cppreference.com
 
 
Utilities library
General utilities
Relational operators (deprecated in C++20)
Integer comparison functions
(C++20)(C++20)(C++20)    
(C++20)
Swap and type operations
(C++14)
(C++11)
(C++11)
(C++11)
(C++17)
Common vocabulary types
(C++11)
(C++17)
(C++17)
(C++17)
(C++11)
(C++17)
(C++23)



 
 
~any();
(since C++17)

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

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

Output:

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

See also

destroys contained object
(public member function) [edit]