[hive.modifiers] # 23 Containers library [[containers]](./#containers) ## 23.3 Sequence containers [[sequences]](sequences#hive.modifiers) ### 23.3.9 Class template hive [[hive]](hive#modifiers) #### 23.3.9.4 Modifiers [hive.modifiers] [🔗](#lib:emplace,hive) `template iterator emplace(Args&&... args); template iterator emplace_hint(const_iterator hint, Args&&... args); ` [1](#1) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8639) *Preconditions*: T is *Cpp17EmplaceConstructible* into hive from args[.](#1.sentence-1) [2](#2) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8643) *Effects*: Inserts an object of type T constructed with std​::​forward(args)...[.](#2.sentence-1) The hint parameter is ignored[.](#2.sentence-2) If an exception is thrown, there are no effects[.](#2.sentence-3) [*Note [1](#note-1)*: args can directly or indirectly refer to a value in *this[.](#2.sentence-4) — *end note*] [3](#3) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8653) *Returns*: An iterator that points to the new element[.](#3.sentence-1) [4](#4) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8657) *Complexity*: Constant[.](#4.sentence-1) Exactly one object of type T is constructed[.](#4.sentence-2) [5](#5) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8661) *Remarks*: Invalidates the past-the-end iterator[.](#5.sentence-1) [🔗](#lib:insert,hive) `iterator insert(const T& x); iterator insert(const_iterator hint, const T& x); iterator insert(T&& x); iterator insert(const_iterator hint, T&& x); ` [6](#6) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8675) *Effects*: Equivalent to: return emplace(std​::​forward(x)); [*Note [2](#note-2)*: The hint parameter is ignored[.](#6.sentence-1) — *end note*] [🔗](#lib:insert,hive_) `void insert(initializer_list rg); template<[container-compatible-range](container.intro.reqmts#concept:container-compatible-range "23.2.2.1 Introduction [container.intro.reqmts]") R> void insert_range(R&& rg); ` [7](#7) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8691) *Preconditions*: T is *Cpp17EmplaceInsertable* into hive from *ranges​::​begin(rg)[.](#7.sentence-1) rg and *this do not overlap[.](#7.sentence-2) [8](#8) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8697) *Effects*: Inserts copies of elements in rg[.](#8.sentence-1) Each iterator in the range rg is dereferenced exactly once[.](#8.sentence-2) [9](#9) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8702) *Complexity*: Linear in the number of elements inserted[.](#9.sentence-1) Exactly one object of type T is constructed for each element inserted[.](#9.sentence-2) [10](#10) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8707) *Remarks*: If an element is inserted, invalidates the past-the-end iterator[.](#10.sentence-1) [🔗](#lib:insert,hive__) `void insert(size_type n, const T& x); ` [11](#11) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8718) *Preconditions*: T is *Cpp17CopyInsertable* into hive[.](#11.sentence-1) [12](#12) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8722) *Effects*: Inserts n copies of x[.](#12.sentence-1) [13](#13) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8726) *Complexity*: Linear in n[.](#13.sentence-1) Exactly one object of type T is constructed for each element inserted[.](#13.sentence-2) [14](#14) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8731) *Remarks*: If an element is inserted, invalidates the past-the-end iterator[.](#14.sentence-1) [🔗](#lib:insert,hive___) `template void insert(InputIterator first, InputIterator last); ` [15](#15) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8743) *Effects*: Equivalent to insert_range(ranges​::​subrange(first, last))[.](#15.sentence-1) [🔗](#lib:erase,hive) `iterator erase(const_iterator position); iterator erase(const_iterator first, const_iterator last); ` [16](#16) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8755) *Complexity*: Linear in the number of elements erased[.](#16.sentence-1) Additionally, if any active blocks become empty of elements as a result of the function call, at worst linear in the number of element blocks[.](#16.sentence-2) [17](#17) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8762) *Remarks*: Invalidates references, pointers and iterators referring to the erased elements[.](#17.sentence-1) An erase operation that erases the last element in *this also invalidates the past-the-end iterator[.](#17.sentence-2) [🔗](#lib:swap,hive) `void swap(hive& x) noexcept(allocator_traits::propagate_on_container_swap::value || allocator_traits::is_always_equal::value); ` [18](#18) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8778) *Effects*: Exchanges the contents, capacity(), and *current-limits* of *this with that of x[.](#18.sentence-1) [19](#19) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L8783) *Complexity*: Constant[.](#19.sentence-1)