[unord.set.modifiers]

# 23 Containers library [[containers]](./#containers)

## 23.5 Unordered associative containers [[unord]](unord#set.modifiers)

### 23.5.6 Class template unordered_set [[unord.set]](unord.set#modifiers)

#### 23.5.6.4 Modifiers [unord.set.modifiers]

[ð](#lib:insert,unordered_set)

`template<class K> constexpr pair<iterator, bool> insert(K&& obj);
template<class K> constexpr iterator insert(const_iterator hint, K&& obj);
`

[1](#1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L15070)

*Constraints*: The [*qualified-id*](expr.prim.id.qual#nt:qualified-id "7.5.5.3 Qualified names [expr.prim.id.qual]")*s* Hash​::​is_transparent andPred​::​is_transparent are valid and denote types[.](#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#L15078)

*Preconditions*: value_type is *Cpp17EmplaceConstructible* into unordered_set from std​::​forward<K>  
(obj)[.](#2.sentence-1)

[3](#3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L15083)

*Effects*: If the set already contains an element that is equivalent to obj,
there is no effect[.](#3.sentence-1)

Otherwise, let h be hash_function()(obj)[.](#3.sentence-2)

Constructs an object u of type value_type with std​::​forward<K>(obj)[.](#3.sentence-3)

If hash_function()(u) != h || contains(u) is true,
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#L15094)

*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 obj[.](#4.sentence-2)

[5](#5)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L15102)

*Complexity*: Average case constant, worst case linear[.](#5.sentence-1)
