[flat.set.modifiers] (original) (raw)
23 Containers library [containers]
23.6 Container adaptors [container.adaptors]
23.6.11 Class template flat_set [flat.set]
23.6.11.5 Modifiers [flat.set.modifiers]
template<class K> constexpr pair<iterator, bool> insert(K&& x);template<class K> constexpr iterator insert(const_iterator hint, K&& x);
Constraints: The qualified-id Compare::is_transparentis valid and denotes a type.
is_constructible_v<value_type, K> is true.
Preconditions: The conversion from x into value_type constructs an object u, for which find(x) == find(u) is true.
Effects: If the set already contains an element equivalent to x,*this and x are unchanged.
Otherwise, inserts a new element as if by emplace(std::forward<K>(x)).
Returns: In the first overload, the bool component of the returned pair is trueif and only if the insertion took place.
The returned iterator points to the element whose key is equivalent to x.
template<class InputIterator> constexpr void insert(InputIterator first, InputIterator last);
Effects: Adds elements to c as if by:c.insert(c.end(), first, last);
Then, sorts the range of newly inserted elements with respect to compare; merges the resulting sorted range and the sorted range of pre-existing elements into a single sorted range; and finally erases all but the first element from each group of consecutive equivalent elements.
Complexity: N + , where N is size() before the operation andM is distance(first, last).
Remarks: Since this operation performs an in-place merge, it may allocate memory.
template<class InputIterator> constexpr void insert(sorted_unique_t, InputIterator first, InputIterator last);
Effects: Equivalent to insert(first, last).
Effects: Adds elements to c as if by:for (const auto& e : rg) { c.insert(c.end(), e);}
Then, sorts the range of newly inserted elements with respect to compare; merges the resulting sorted range and the sorted range of pre-existing elements into a single sorted range; and finally erases all but the first element from each group of consecutive equivalent elements.
Complexity: N + , where N is size() before the operation and Mis ranges::distance(rg).
Remarks: Since this operation performs an in-place merge, it may allocate memory.
constexpr void swap(flat_set& y) noexcept;
Effects: Equivalent to:ranges::swap(compare, y.compare); ranges::swap(c, y.c);
Postconditions: *this is emptied, even if the function exits via an exception.
constexpr void replace(container_type&& cont);
Preconditions: The elements of cont are sorted with respect to compare, andcont contains no equal elements.
Effects: Equivalent to: c = std::move(cont);