命名空间
变体
操作

std::any::reset

来自 cppreference.cn
< cpp‎ | utility‎ | 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());
}

[编辑] 参见

检查对象是否包含值
(公共成员函数) [编辑]