std::flat_m...map::extract(3)
π std::flat_multimap::extract π
okay so bestie, this is the std::flat_m...map::extract(3) page from the C++ Standard Libary manual β and yes, βLibaryβ is literally spelled that way up top, we are not fixing the lore, we respect the lore. π«Ά Itβs giving very niche C++23 container magic, and honestly? iconic.
β¨ NAME β¨
std::flat_multimap::extract - std::flat_multimap::extract
β¨ Synopsis β¨
containers extract() &&; (since C++23)
It extracts adapted containers c. Equivalent to return std::move(c);.
After this operation *this is empty, even if an exception is thrown. Like, the emptiness is not canceled by drama β periodt. π
πΈ Parameters πΈ
(none) β no parameters, not a single one, we love a low-maintenance icon. β¨
π Return value π
It returns std::move(c).
π¦ Complexity π¦
Constant. Thatβs the whole vibe: constant, no stress, no loops, just slay. π₯
π Example π
The page even drops a lil // Run this code before the snippet:
#include <cassert>
#include <flat_map>
#include <print>
#include <type_traits>
#include <vector>
int main()
{
std::flat_multimap<int, double> map{{1, 1.1}, {2, 2.2}, {3, 3.3}};
const auto size = map.size();
auto c = map.extract();
assert(c.keys.size() == size);
assert(c.values.size() == size);
assert(map.empty());
assert(map.keys().empty());
assert(map.values().empty());
// The default keys and values containers are std::vector:
static_assert(std::is_same_v<decltype(c.keys), std::vector<int>>);
static_assert(std::is_same_v<decltype(c.value), std::vector<int>>);
std::println("keys: {}", c.keys);
std::println("values: {}", c.values);
}
π Output π
keys: [1, 2, 3]
values: [1.1, 2.2, 3.3]
π See also π
replaceβ replaces the underlying containers (public member function). thatβs the cross-reference, bestie, go get the container-swap tea π΅
xoxo, your fave little reference page β source is http://cppreference.com, dated 2024.06.10, and the title again is std::flat_m...map::extract(3). bye bestie π
π¦ 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