std::flat_m...set::replace(3)
π
std::flat_m...set::replace(3) π
okay so bestie, this page is from the C++ Standard Libary manual, and it's literally about swapping out the underlying container for a std::flat_multiset. lowkey iconic.
β¨ NAME β¨
std::flat_multiset::replace β std::flat_multiset::replace
π¦ Synopsis π¦
void replace( container_type&& cont ); (since C++23)
She replaces the underlying container c, and it's equivalent to this move moment:
c = std::move(cont);
The elements of cont must be sorted with respect to compare. Otherwise, the behavior is undefined. π«£π¨
πΈ Parameters πΈ
contβ a sorted container of typeKeyContainer, the contents of which will be moved into*this
π Return value π
(none) β she gives nothing back, and honestly? mood. π
π₯ Complexity π₯
Equals to complexity of std::move applied to adapted container.
π Example π
// Run this code
#include <algorithm>
#include <cassert>
#include <flat_set>
#include <print>
#include <vector>
int main()
{
std::vector<int> keys{1, 2, 3};
assert(std::ranges::is_sorted(keys));
std::flat_multiset<int> set;
assert(set.empty());
set.replace(keys);
assert(set.size() == 3);
assert(keys.empty());
std::println("{}", set); // set.keys()
}
π¨οΈ Output π¨οΈ
[1, 2, 3]
π See also π
extractβ extracts the underlying container (public member function)
mwah π this little love letter came from http://cppreference.com, dated 2024.06.10, and the page is std::flat_m...set::replace(3) β periodt. πβ¨
π¦ 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