名稱空間
變體
操作

std::any::reset

來自 cppreference.com
< cpp‎ | 工具‎ | any
 
 
 
 
void reset() noexcept;
(C++17 起)

如果 *this 包含一個值,則銷燬所包含的值。

此呼叫後,*this 不再包含任何值。

目錄

[編輯] 引數

(無)

[編輯] 返回值

(無)

[編輯] 示例

#include <any>
#include <cassert>
 
int main()
{
    std::any a{42};
    assert(a.has_value());
    a.reset();
    assert(not a.has_value());
}

[編輯] 參閱

檢查物件是否包含值
(公有成員函式) [編輯]