# std::any::reset

> C++ Atlas: `cppatlas.com/w/cpp/utility/any/reset` | Source: https://en.cppreference.com/w/cpp/utility/any/reset | Domain: Utility | Standards: C++17

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

## Official Specification Summary (cppreference)

```cpp
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

```cpp
#include <any>
#include <cassert>

int main()
{
    std::any a{42};
    assert(a.has_value());
    a.reset();
    assert(not a.has_value());
}
```

### See also

- [`has_value`](https://en.cppreference.com/w/cpp/utility/any/has_value): checks if object holds a value (public member function)

---
Attribution: content from https://en.cppreference.com/w/cpp/utility/any/reset (cppreference.com), licensed under CC-BY-SA 3.0 and GFDL. Modified: converted to markdown, study notes added. Offline snapshot of 9 February 2025.