std::flat_m...set::extract(3)
πΈ NAME πΈ
okay so bestie, this is std::flat_multiset::extract β the manual name in the header is std::flat_m...set::extract(3), and itβs from the C++ Standard Libary (yes, that spelling is in the header, iykyk π). It extracts the adapted container c and leaves *this empty. Iconic behavior, honestly. π
β¨ Synopsis β¨
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 β like, the empty-state commitment is real, no cap. π«Ά
π Parameters π
(none) β literally no parameters. Zero. Nada. Bestie, there is nothing to pass in here. π
π«Ά Return value π«Ά
std::move(c).
Thatβs the whole return value. Slay. β¨
β‘ Complexity β‘
Constant.
Thatβs it. Thatβs the complexity. No dramatic twist. π
π§ Example π§
// Run this code
#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 π
[1, 2, 3]
π See also π
replaceβ replaces the underlying container (public member function)
okay bye bestie π«Ά this was the std::flat_m...set::extract(3) page from source/version http://cppreference.com, dated 2024.06.10, and the footer manual name is std::flat_m...set::extract(3) β mwah πβ¨π
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms