[unord.set.modifiers] (original) (raw)

23 Containers library [containers]

23.5 Unordered associative containers [unord]

23.5.6 Class template unordered_set [unord.set]

23.5.6.4 Modifiers [unord.set.modifiers]

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

Constraints: The qualified-ids Hash​::​is_transparent andPred​::​is_transparent are valid and denote types.

For the second overload,is_convertible_v<K&&, const_iterator> andis_convertible_v<K&&, iterator> are both false.

Preconditions: value_type is _Cpp17EmplaceConstructible_into unordered_set from std​::​forward<K>
(obj).

Effects: If the set already contains an element that is equivalent to obj, there is no effect.

Otherwise, let h be hash_function()(obj).

Constructs an object u of type value_typewith std​::​forward<K>(obj).

If hash_function()(u) != h || contains(u) is true, the behavior is undefined.

Inserts u into *this.

Returns: For 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 set element that is equivalent to obj.

Complexity: Average case constant, worst case linear.