(C++17) | ||||
| Sequence | ||||
(C++11) | ||||
(C++26) | ||||
(C++26) | ||||
(C++11) | ||||
| Associative | ||||
| Unordered associative | ||||
(C++11) | ||||
(C++11) | ||||
(C++11) | ||||
(C++11) | ||||
| Adaptors | ||||
(C++23) | ||||
(C++23) | ||||
(C++23) | ||||
(C++23) | ||||
| Views | ||||
(C++20) | ||||
(C++23) | ||||
| Tables | ||||
| Iterator invalidation | ||||
| Member function table | ||||
| Non-member function table |
void replace( container_type&& cont); | (since C++23) | |
Replaces the underlying containerc. Equivalent to:c= std::move(cont);.
The elements ofcont must be sorted with respect tocompare, andcont must not contain equal elements. Otherwise, the behavior is undefined.
Contents |
| cont | - | a sorted container of typeKeyContainer, the contents of which will be moved into*this |
(none)
Equals to complexity ofstd::move applied to adapted container.
#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_set<int> set;assert(set.empty()); set.replace(keys);assert(set.size()==3);assert(keys.empty()); std::println("{}", set);// set.keys()}
Output:
[1, 2, 3]
| extracts the underlying container (public member function)[edit] |