std::flat_multiset<Key,Compare,KeyContainer>::extract
container_type extract() &&; | (начиная с C++23) |
Извлекает адаптированный контейнер c. Эквивалентно return std::move(c);.
После этой операции *this пуст, даже если было выброшено исключение.
Возвращаемое значение
std::move(c).
Сложность
Константная.
Пример
#include <cassert>
#include <flat_set>
#include <print>
#include <type_traits>
#include <utility>
#include <vector>
int main()
{
std::flat_multiset<int> set{1, 2, 3};
const auto size{set.size()};
auto c{std::move(set).extract()};
assert(c.size() == size);
assert(set.empty());
// The default keys container is std::vector:
static_assert(std::is_same_v<decltype(c), std::vector<int>>);
std::println("{}", c);
}
Вывод:
[1, 2, 3]
См. также
| заменяет базовый контейнер (открытая функция-член) |
© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
https://en.cppreference.com/cpp/container/flat_multiset/extract