Skip to content

Commit df94fa4

Browse files
committed
Merge 2014-11 LWG Motion 17
2 parents f8b5d6c + b3818e5 commit df94fa4

1 file changed

Lines changed: 168 additions & 0 deletions

File tree

‎source/containers.tex‎

Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5581,6 +5581,23 @@
55815581
void insert(InputIterator first, InputIterator last);
55825582
void insert(initializer_list<value_type>);
55835583

5584+
template <class... Args>
5585+
pair<iterator, bool> try_emplace(const key_type& k, Args&&... args);
5586+
template <class... Args>
5587+
pair<iterator, bool> try_emplace(key_type&& k, Args&&... args);
5588+
template <class... Args>
5589+
iterator try_emplace(const_iterator hint, const key_type& k, Args&&... args);
5590+
template <class... Args>
5591+
iterator try_emplace(const_iterator hint, key_type&& k, Args&&... args);
5592+
template <class M>
5593+
pair<iterator, bool> insert_or_assign(const key_type& k, M&& obj);
5594+
template <class M>
5595+
pair<iterator, bool> insert_or_assign(key_type&& k, M&& obj);
5596+
template <class M>
5597+
iterator insert_or_assign(const_iterator hint, const key_type& k, M&& obj);
5598+
template <class M>
5599+
iterator insert_or_assign(const_iterator hint, key_type&& k, M&& obj);
5600+
55845601
iterator erase(const_iterator position);
55855602
size_type erase(const key_type& x);
55865603
iterator erase(const_iterator first, const_iterator last);
@@ -5806,6 +5823,73 @@
58065823
\tcode{true}.
58075824
\end{itemdescr}
58085825

5826+
\indexlibrary{\idxcode{try_emplace}!\idxcode{map}}%
5827+
\indexlibrary{\idxcode{map}!\idxcode{try_emplace}}%
5828+
\begin{itemdecl}
5829+
template <class... Args> pair<iterator, bool> try_emplace(const key_type& k, Args&&... args);
5830+
template <class... Args> pair<iterator, bool> try_emplace(key_type&& k, Args&&... args);
5831+
template <class... Args> iterator try_emplace(const_iterator hint, const key_type& k, Args&&... args);
5832+
template <class... Args> iterator try_emplace(const_iterator hint, key_type&& k, Args&&... args);
5833+
\end{itemdecl}
5834+
5835+
\begin{itemdescr}
5836+
\pnum
5837+
\effects
5838+
If the key \tcode{k} already exists in the map, there is no effect.
5839+
Otherwise, inserts an element into the map.
5840+
In the first and third forms,
5841+
the element is constructed from the arguments as
5842+
\tcode{value_type(k, std::forward<Args>(args)...)}.
5843+
In the second and fourth forms,
5844+
the element is constructed from the arguments as
5845+
\tcode{value_type(std::move(k), std::forward<Args>(args)...)}.
5846+
In the first two overloads,
5847+
the \tcode{bool} component of the returned pair is \tcode{true}
5848+
if and only if the insertion took place.
5849+
The returned \tcode{iterator} points to the element of the map whose key
5850+
is equivalent to \tcode{k}.
5851+
5852+
\pnum
5853+
\complexity
5854+
The same as \tcode{emplace} and \tcode{emplace_hint},
5855+
respectively.
5856+
\end{itemdescr}
5857+
5858+
\indexlibrary{\idxcode{insert_or_assign}!\idxcode{map}}%
5859+
\indexlibrary{\idxcode{map}!\idxcode{insert_or_assign}}%
5860+
\begin{itemdecl}
5861+
template <class M> pair<iterator, bool> insert_or_assign(const key_type& k, M&& obj);
5862+
template <class M> pair<iterator, bool> insert_or_assign(key_type&& k, M&& obj);
5863+
template <class M> iterator insert_or_assign(const_iterator hint, const key_type& k, M&& obj);
5864+
template <class M> iterator insert_or_assign(const_iterator hint, key_type&& k, M&& obj);
5865+
\end{itemdecl}
5866+
5867+
\begin{itemdescr}
5868+
\pnum
5869+
\effects
5870+
If the key \tcode{k} does not exist in the map,
5871+
inserts an element into the map.
5872+
In the first and third forms,
5873+
the element is constructed from the arguments as
5874+
\tcode{value_type(k, std::forward<Args>(args)...)}.
5875+
In the second and fourth forms,
5876+
the element is constructed from the arguments as
5877+
\tcode{value_type(std::move(k), std::forward<Args>(args)...)}.
5878+
If the key already exists,
5879+
\tcode{std::forward<M>(obj)} is assigned to the
5880+
\tcode{mapped_type} corresponding to the key.
5881+
In the first two overloads,
5882+
the \tcode{bool} component of the returned value is \tcode{true}
5883+
if and only if the insertion took place.
5884+
The returned \tcode{iterator} points to the element
5885+
that was inserted or updated.
5886+
5887+
\pnum
5888+
\complexity
5889+
The same as \tcode{emplace} and \tcode{emplace_hint},
5890+
respectively.
5891+
\end{itemdescr}
5892+
58095893
\rSec3[map.special]{\tcode{map} specialized algorithms}
58105894

58115895
\indexlibrary{\idxcode{swap}!\idxcode{map}}%
@@ -6905,6 +6989,23 @@
69056989
template <class InputIterator> void insert(InputIterator first, InputIterator last);
69066990
void insert(initializer_list<value_type>);
69076991

6992+
template <class... Args>
6993+
pair<iterator, bool> try_emplace(const key_type& k, Args&&... args);
6994+
template <class... Args>
6995+
pair<iterator, bool> try_emplace(key_type&& k, Args&&... args);
6996+
template <class... Args>
6997+
iterator try_emplace(const_iterator hint, const key_type& k, Args&&... args);
6998+
template <class... Args>
6999+
iterator try_emplace(const_iterator hint, key_type&& k, Args&&... args);
7000+
template <class M>
7001+
pair<iterator, bool> insert_or_assign(const key_type& k, M&& obj);
7002+
template <class M>
7003+
pair<iterator, bool> insert_or_assign(key_type&& k, M&& obj);
7004+
template <class M>
7005+
iterator insert_or_assign(const_iterator hint, const key_type& k, M&& obj);
7006+
template <class M>
7007+
iterator insert_or_assign(const_iterator hint, key_type&& k, M&& obj);
7008+
69087009
iterator erase(const_iterator position);
69097010
size_type erase(const key_type& k);
69107011
iterator erase(const_iterator first, const_iterator last);
@@ -7104,6 +7205,73 @@
71047205
unless \tcode{std::is_constructible<value_type, P\&\&>::value} is \tcode{true}.
71057206
\end{itemdescr}
71067207

7208+
\indexlibrary{\idxcode{try_emplace}!\idxcode{unordered_map}}%
7209+
\indexlibrary{\idxcode{unordered_map}!\idxcode{try_emplace}}%
7210+
\begin{itemdecl}
7211+
template <class... Args> pair<iterator, bool> try_emplace(const key_type& k, Args&&... args);
7212+
template <class... Args> pair<iterator, bool> try_emplace(key_type&& k, Args&&... args);
7213+
template <class... Args> iterator try_emplace(const_iterator hint, const key_type& k, Args&&... args);
7214+
template <class... Args> iterator try_emplace(const_iterator hint, key_type&& k, Args&&... args);
7215+
\end{itemdecl}
7216+
7217+
\begin{itemdescr}
7218+
\pnum
7219+
\effects
7220+
If the key \tcode{k} already exists in the map, there is no effect.
7221+
Otherwise, inserts an element into the map.
7222+
In the first and third forms,
7223+
the element is constructed from the arguments as
7224+
\tcode{value_type(k, std::forward<Args>(args)...)}.
7225+
In the second and fourth forms,
7226+
the element is constructed from the arguments as
7227+
\tcode{value_type(std::move(k), std::forward<Args>(args)...)}.
7228+
In the first two overloads,
7229+
the \tcode{bool} component of the returned pair is \tcode{true}
7230+
if and only if the insertion took place.
7231+
The returned \tcode{iterator} points to the element of the map whose key
7232+
is equivalent to \tcode{k}.
7233+
7234+
\pnum
7235+
\complexity
7236+
The same as \tcode{emplace} and \tcode{emplace_hint},
7237+
respectively.
7238+
\end{itemdescr}
7239+
7240+
\indexlibrary{\idxcode{insert_or_assign}!\idxcode{unordered_map}}%
7241+
\indexlibrary{\idxcode{unordered_map}!\idxcode{insert_or_assign}}%
7242+
\begin{itemdecl}
7243+
template <class M> pair<iterator, bool> insert_or_assign(const key_type& k, M&& obj);
7244+
template <class M> pair<iterator, bool> insert_or_assign(key_type&& k, M&& obj);
7245+
template <class M> iterator insert_or_assign(const_iterator hint, const key_type& k, M&& obj);
7246+
template <class M> iterator insert_or_assign(const_iterator hint, key_type&& k, M&& obj);
7247+
\end{itemdecl}
7248+
7249+
\begin{itemdescr}
7250+
\pnum
7251+
\effects
7252+
If the key \tcode{k} does not exist in the map,
7253+
inserts an element into the map.
7254+
In the first and third forms,
7255+
the element is constructed from the arguments as
7256+
\tcode{value_type(k, std::forward<Args>(args)...)}.
7257+
In the second and fourth forms,
7258+
the element is constructed from the arguments as
7259+
\tcode{value_type(std::move(k), std::forward<Args>(args)...)}.
7260+
If the key already exists,
7261+
\tcode{std::forward<M>(obj)} is assigned to the
7262+
\tcode{mapped_type} corresponding to the key.
7263+
In the first two overloads,
7264+
the \tcode{bool} component of the returned value is \tcode{true}
7265+
if and only if the insertion took place.
7266+
The returned \tcode{iterator} points to the element
7267+
that was inserted or updated.
7268+
7269+
\pnum
7270+
\complexity
7271+
The same as \tcode{emplace} and \tcode{emplace_hint},
7272+
respectively.
7273+
\end{itemdescr}
7274+
71077275
\rSec3[unord.map.swap]{\tcode{unordered_map} swap}
71087276

71097277
\indexlibrary{\idxcode{unordered_map}!\idxcode{swap}}%

0 commit comments

Comments
 (0)