std::flat_m...set::extract(3)

πŸ“¦ version 2024.07.05, in nixpkgs unstable, opensuse-leap 16.0

🌸 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