# std::flat_multiset<Key,Compare,KeyContainer>::extract

> C++ Atlas: `cppatlas.com/w/cpp/container/flat_multiset/extract` | Source: https://en.cppreference.com/w/cpp/container/flat_multiset/extract | Domain: Containers | Standards: C++23

Extracts adapted container c. Equivalent to return std::move(c);.

## Official Specification Summary (cppreference)

```cpp
container_type extract() &&; // (since C++23)
```

Extracts adapted container `c`. Equivalent to `return std::move(c);`.

After this operation `*this` is empty, even if an exception is thrown.

### Parameters

(none)

### Return value

`std::move(c)`.

### Complexity

Constant.

### Example

```cpp
#include <cassert>
#include <flat_set>
#include <print>
#include <type_traits>
#include <vector>

int main()
{
    std::flat_multiset<int> set{1, 2, 3};
    const auto size = set.size();

    auto c = set.extract();
    assert(c.size() == size);
    assert(set.empty());
    assert(set.keys().empty());
    assert(set.values().empty());

    // The default keys container is std::vector:
    static_assert(std::is_same_v<decltype(c), std::vector<int>>);

    std::println("{}", c);
}
```

Output:

```text
[1, 2, 3]
```

### See also

- [`replace`](https://en.cppreference.com/w/cpp/container/flat_multiset/replace): replaces the underlying container (public member function)

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