Skip to content

Search topics & cppreference

Search all study topics, concept maps, and 6,587 C++ and C reference pages.

std::any::reset

If *this contains a value, destroys the contained value.

NotebookLM
void reset() noexcept;
(since C++17)

If *this contains a value, destroys the contained value.

*this does not contain a value after this call.

Parameters

(none)

Return value

(none)

Example

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

See also

checks if object holds a value
(public member function)

Content from this page on cppreference.com, licensed under CC-BY-SA 3.0 and GFDL. Modified: restyled, site navigation removed, code windows added. Offline snapshot of 9 February 2025.