std::swap(std::flat_set)(3)
πΈ NAME πΈ
This is the std::swap(std::flat_set) page from the C++ Standard Libary manual, bestie.
std::swap(std::flat_set) - std::swap(std::flat_set) β yes, the NAME section is literally the same thing twice, and that's iconic. π
β¨ Synopsis β¨
Defined in header <flat_set>
friend void swap( std::flat_set& lhs, std::flat_set& rhs ) noexcept;
It's marked (since C++23), and it specializes the std::swap algorithm for std::flat_set. It swaps the contents of lhs and rhs, and calls lhs.swap(rhs). π«Ά
π Parameters π
lhs,rhsβ containers whose contents to swap. Two containers, one little swap moment. π
π Return value π
(none) β literally nothing comes back, bestie. No return value, just vibes. π
π₯ Complexity π₯
Same as swapping the underlying container. That's the complexity, no extra lore. β¨
π Example π
The example says // Run this code β so go run it:
#include <algorithm>
#include <iostream>
#include <flat_set>
int main()
{
std::flat_set<int> alice{1, 2, 3};
std::flat_set<int> bob{7, 8, 9, 10};
auto print = [](const int& n) { std::cout << ' ' << n; };
// Print state before swap
std::cout << "Alice:";
std::for_each(alice.begin(), alice.end(), print);
std::cout << "\n" "Bob :";
std::for_each(bob.begin(), bob.end(), print);
std::cout << '\n';
std::cout << "-- SWAP\n";
std::swap(alice, bob);
// Print state after swap
std::cout << "Alice:";
std::for_each(alice.begin(), alice.end(), print);
std::cout << "\n" "Bob :";
std::for_each(bob.begin(), bob.end(), print);
std::cout << '\n';
}
π Output π
Alice: 1 2 3
Bob : 7 8 9 10
-- SWAP
Alice: 7 8 9 10
Bob : 1 2 3
π See also π
swapβ swaps the contents (public member function). Yep, that's the member-function bestie. π
Source/version/date sign-off: http://cppreference.com β 2024.06.10 β page std::swap(std::flat_set)(3). Byeee, go swap your flat_sets responsibly π
π¦ 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