std::flat_set::extract(3)
πΈ NAME πΈ
std::flat_set::extract - std::flat_set::extract
okay so bestie, welcome to std::flat_set::extract(3) from the C++ Standard Libary page β yes, thatβs the manual name, and weβre about to get into the member function that literally extracts the adapted container. iconic behavior only. π
β¨ 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. fr fr, thatβs the rule β exception or no exception, *this ends up empty. π«Ά
π Parameters π
(none) β zero parameters, bestie. not a single one. π
π Return value π
std::move(c). thatβs the whole return vibe. β¨
π¦ Complexity π¦
Constant. no extra drama, no cap. π
π Example π
// Run this code
#include <cassert>
#include <flat_set>
#include <print>
#include <type_traits>
#include <vector>
int main()
{
std::flat_set<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)
bye bestie π«Ά this pageβs source/version is http://cppreference.com, dated 2024.06.10, and the footer tag is std::flat_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