template <class P>
pair<iterator, bool> insert(P&& x);
template <class P>
iterator insert(const_iterator position, P&& x);
Effects:
The first form is equivalent to
return emplace(std::forward<P>(x)). The second form is
equivalent to
return emplace_hint(position, std::forward<P>(x)).Remarks:
These signatures shall not participate in overload resolution
unless
is_constructible_v<value_type, P&&> is
true. template <class... Args>
pair<iterator, bool> try_emplace(const key_type& k, Args&&... args);
template <class... Args>
iterator try_emplace(const_iterator hint, const key_type& k, Args&&... args);
Requires:
value_type shall be
EmplaceConstructible into
map
from
piecewise_construct,
forward_as_tuple(k),
forward_as_tuple(std::forward<Args>(args)...). Effects:
If the map already contains an element
whose key is equivalent to
k,
there is no effect
. Otherwise inserts an object of type
value_type
constructed with
piecewise_construct,
forward_as_tuple(k),
forward_as_tuple(std::forward<Args>(args)...).Returns:
In the first overload,
the
bool component of the returned pair is
true
if and only if the insertion took place
. The returned iterator points to the map element
whose key is equivalent to
k.Complexity:
The same as
emplace and
emplace_hint,
respectively
. template <class... Args>
pair<iterator, bool> try_emplace(key_type&& k, Args&&... args);
template <class... Args>
iterator try_emplace(const_iterator hint, key_type&& k, Args&&... args);
Requires:
value_type shall be
EmplaceConstructible into
map
from
piecewise_construct,
forward_as_tuple(std::move(k)),
forward_as_tuple(std::forward<Args>(args)...). Effects:
If the map already contains an element
whose key is equivalent to
k,
there is no effect
. Otherwise inserts an object of type
value_type
constructed with
piecewise_construct,
forward_as_tuple(std::move(k)),
forward_as_tuple(std::forward<Args>(args)...).Returns:
In the first overload,
the
bool component of the returned pair is
true
if and only if the insertion took place
. The returned iterator points to the map element
whose key is equivalent to
k.Complexity:
The same as
emplace and
emplace_hint,
respectively
. template <class M>
pair<iterator, bool> insert_or_assign(const key_type& k, M&& obj);
template <class M>
iterator insert_or_assign(const_iterator hint, const key_type& k, M&& obj);
Requires:
is_assignable_v<mapped_type&, M&&> shall be
true. value_type shall be
EmplaceConstructible into
map
from
k,
forward<M>(obj). Effects:
If the map already contains an element
e
whose key is equivalent to
k,
assigns
std::forward<M>(obj) to
e.second. Otherwise inserts an object of type
value_type
constructed with
k,
std::forward<M>(obj).Returns:
In the first overload,
the
bool component of the returned pair is
true
if and only if the insertion took place
. The returned iterator points to the map element
whose key is equivalent to
k.Complexity:
The same as
emplace and
emplace_hint,
respectively
. template <class M>
pair<iterator, bool> insert_or_assign(key_type&& k, M&& obj);
template <class M>
iterator insert_or_assign(const_iterator hint, key_type&& k, M&& obj);
Requires:
is_assignable_v<mapped_type&, M&&> shall be
true. value_type shall be
EmplaceConstructible into
map
from
move(k),
forward<M>(obj). Effects:
If the map already contains an element
e
whose key is equivalent to
k,
assigns
std::forward<M>(obj) to
e.second. Otherwise inserts an object of type
value_type
constructed with
std::move(k),
std::forward<M>(obj).Returns:
In the first overload,
the
bool component of the returned pair is
true
if and only if the insertion took place
. The returned iterator points to the map element
whose key is equivalent to
k.Complexity:
The same as
emplace and
emplace_hint,
respectively
.