(C++17) | ||||
| Sequence | ||||
(C++11) | ||||
(C++26) | ||||
(C++26) | ||||
(C++11) | ||||
| Associative | ||||
| Unordered associative | ||||
(C++11) | ||||
(C++11) | ||||
(C++11) | ||||
(C++11) | ||||
| Adaptors | ||||
(C++23) | ||||
(C++23) | ||||
(C++23) | ||||
(C++23) | ||||
| Views | ||||
(C++20) | ||||
(C++23) | ||||
| Tables | ||||
| Iterator invalidation | ||||
| Member function table | ||||
| Non-member function table |
std::pair<iterator,bool> insert(const value_type& value); | (1) | (since C++23) |
std::pair<iterator,bool> insert( value_type&& value); | (2) | (since C++23) |
iterator insert( const_iterator pos,const value_type& value); | (3) | (since C++23) |
iterator insert( const_iterator pos, value_type&& value); | (4) | (since C++23) |
template<class P> std::pair<iterator,bool> insert( P&& x); | (5) | (since C++23) |
template<class P> iterator insert( const_iterator pos, P&& x); | (6) | (since C++23) |
template<class InputIt> void insert( InputIt first, InputIt last); | (7) | (since C++23) |
template<class InputIt> void insert(std::sorted_unique_t, InputIt first, InputIt last); | (8) | (since C++23) |
void insert(std::initializer_list<key_type> ilist); | (9) | (since C++23) |
void insert(std::sorted_unique_t s,std::initializer_list<key_type> ilist); | (10) | (since C++23) |
Inserts element(s) into the container, if the container does not already contain an element with an equivalent key.
x into*this as if byemplace(std::forward<P>(x));. This overload participates in overload resolution only ifstd::is_constructible_v<std::pair<key_type, mapped_type>, P> istrue.x into*this in the position as close as possible to the position just prior topos. Equivalent toreturn emplace_hint(pos,std::forward<P>(x));. This overload participates in overload resolution only ifstd::is_constructible_v<std::pair<key_type, mapped_type>, P> istrue.[first, last) as if performing the following operations sequentially:c as if byvalue_comp.[first, last) as if performing the following operations sequentially:c as if by| Information on iterator invalidation is copied fromhere |
Contents |
| pos | - | an iterator to the position before which the new element will be inserted |
| value | - | an element value to insert |
| first, last | - | the pair of iterators defining the sourcerange of elements to insert |
| ilist | - | an initializer list to insert the values from |
| x | - | a value of any type that can be transparently compared with a key |
| s | - | a disambiguation tag indicating that the input sequence is sorted (with respect tovalue_comp()) and contains only unique elements |
| Type requirements | ||
-InputIt must meet the requirements ofLegacyInputIterator. | ||
| This section is incomplete Reason: cases 7-10 |
size().size().The hinted insert((3,4) and(6))does not return a boolean in order to be signature-compatible with positional insert on sequential containers, such asstd::vector::insert. This makes it possible to create generic inserters such asstd::inserter. One way to check success of a hinted insert is to comparesize() before and after.
| This section is incomplete Reason: no example |
| constructs element in-place (public member function)[edit] | |
| constructs elements in-place using a hint (public member function)[edit] | |
| inserts an element or assigns to the current element if the key already exists (public member function)[edit] | |
| creates astd::insert_iterator of type inferred from the argument (function template)[edit] |