名稱空間
變體
操作

std::any::~any

來自 cppreference.com
< cpp‎ | utility‎ | any
 
 
 
 
~any();
(C++17 起)

如果包含物件,則銷燬它,如同呼叫reset()

[編輯] 示例

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

輸出

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

[編輯] 參閱

銷燬所包含的物件
(public 成員函式) [編輯]