60 lines
2.1 KiB
Markdown
60 lines
2.1 KiB
Markdown
[set.modifiers]
|
||
|
||
# 23 Containers library [[containers]](./#containers)
|
||
|
||
## 23.4 Associative containers [[associative]](associative#set.modifiers)
|
||
|
||
### 23.4.6 Class template set [[set]](set#modifiers)
|
||
|
||
#### 23.4.6.4 Modifiers [set.modifiers]
|
||
|
||
[ð](#lib:insert,set)
|
||
|
||
`template<class K> constexpr pair<iterator, bool> insert(K&& x);
|
||
template<class K> constexpr iterator insert(const_iterator hint, K&& x);
|
||
`
|
||
|
||
[1](#1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L12955)
|
||
|
||
*Constraints*: The [*qualified-id*](expr.prim.id.qual#nt:qualified-id "7.5.5.3 Qualified names [expr.prim.id.qual]") Compare::is_transparent is valid and denotes a type[.](#1.sentence-1)
|
||
|
||
For the second overload,is_convertible_v<K&&, const_iterator> andis_convertible_v<K&&, iterator> are both false[.](#1.sentence-2)
|
||
|
||
[2](#2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L12963)
|
||
|
||
*Preconditions*: value_type is *Cpp17EmplaceConstructible* into set fromstd::forward<K>(x)[.](#2.sentence-1)
|
||
|
||
[3](#3)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L12968)
|
||
|
||
*Effects*: If the set already contains an element that is equivalent to x,
|
||
there is no effect[.](#3.sentence-1)
|
||
|
||
Otherwise, let r be equal_range(x)[.](#3.sentence-2)
|
||
|
||
Constructs an object u of type value_type with std::forward<K>(x)[.](#3.sentence-3)
|
||
|
||
If equal_range(u) == r is false, the behavior is undefined[.](#3.sentence-4)
|
||
|
||
Inserts u into *this[.](#3.sentence-5)
|
||
|
||
[4](#4)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L12978)
|
||
|
||
*Returns*: For the first overload,
|
||
the bool component of the returned pair is true if and only if the insertion took place[.](#4.sentence-1)
|
||
|
||
The returned iterator points to the set element that is equivalent to x[.](#4.sentence-2)
|
||
|
||
[5](#5)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L12985)
|
||
|
||
*Complexity*: Logarithmic[.](#5.sentence-1)
|