mirror of
https://github.com/llvm-mirror/libcxx.git
synced 2025-10-24 12:02:36 +08:00
Mark LWG issue 2469 as done. Also simplify try_emplace and insert_or_assign implementations in unordered_map
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@266591 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -984,117 +984,85 @@ public:
|
|||||||
#endif // _LIBCPP_CXX03_LANG
|
#endif // _LIBCPP_CXX03_LANG
|
||||||
|
|
||||||
#if _LIBCPP_STD_VER > 14
|
#if _LIBCPP_STD_VER > 14
|
||||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
|
||||||
#ifndef _LIBCPP_HAS_NO_VARIADICS
|
|
||||||
template <class... _Args>
|
template <class... _Args>
|
||||||
_LIBCPP_INLINE_VISIBILITY
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
pair<iterator, bool> try_emplace(const key_type& __k, _Args&&... __args)
|
pair<iterator, bool> try_emplace(const key_type& __k, _Args&&... __args)
|
||||||
{
|
{
|
||||||
iterator __p = __table_.find(__k);
|
return __table_.__emplace_unique_key_args(__k, _VSTD::piecewise_construct,
|
||||||
if ( __p != end())
|
_VSTD::forward_as_tuple(__k),
|
||||||
return _VSTD::make_pair(__p, false);
|
_VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...));
|
||||||
else
|
|
||||||
return _VSTD::make_pair(
|
|
||||||
emplace_hint(__p,
|
|
||||||
_VSTD::piecewise_construct, _VSTD::forward_as_tuple(__k),
|
|
||||||
_VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...)),
|
|
||||||
true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class... _Args>
|
template <class... _Args>
|
||||||
_LIBCPP_INLINE_VISIBILITY
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
pair<iterator, bool> try_emplace(key_type&& __k, _Args&&... __args)
|
pair<iterator, bool> try_emplace(key_type&& __k, _Args&&... __args)
|
||||||
{
|
{
|
||||||
iterator __p = __table_.find(__k);
|
return __table_.__emplace_unique_key_args(__k, _VSTD::piecewise_construct,
|
||||||
if ( __p != end())
|
_VSTD::forward_as_tuple(_VSTD::move(__k)),
|
||||||
return _VSTD::make_pair(__p, false);
|
_VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...));
|
||||||
else
|
|
||||||
return _VSTD::make_pair(
|
|
||||||
emplace_hint(__p,
|
|
||||||
_VSTD::piecewise_construct, _VSTD::forward_as_tuple(_VSTD::move(__k)),
|
|
||||||
_VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...)),
|
|
||||||
true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class... _Args>
|
template <class... _Args>
|
||||||
_LIBCPP_INLINE_VISIBILITY
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
iterator try_emplace(const_iterator __h, const key_type& __k, _Args&&... __args)
|
iterator try_emplace(const_iterator __h, const key_type& __k, _Args&&... __args)
|
||||||
{
|
{
|
||||||
iterator __p = __table_.find(__k);
|
#if _LIBCPP_DEBUG_LEVEL >= 2
|
||||||
if ( __p != end())
|
_LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
|
||||||
return __p;
|
"unordered_map::try_emplace(const_iterator, key, args...) called with an iterator not"
|
||||||
else
|
" referring to this unordered_map");
|
||||||
return emplace_hint(__h,
|
#endif
|
||||||
_VSTD::piecewise_construct, _VSTD::forward_as_tuple(__k),
|
return try_emplace(__k, _VSTD::forward<_Args>(__args)...).first;
|
||||||
_VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class... _Args>
|
template <class... _Args>
|
||||||
_LIBCPP_INLINE_VISIBILITY
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
iterator try_emplace(const_iterator __h, key_type&& __k, _Args&&... __args)
|
iterator try_emplace(const_iterator __h, key_type&& __k, _Args&&... __args)
|
||||||
{
|
{
|
||||||
iterator __p = __table_.find(__k);
|
#if _LIBCPP_DEBUG_LEVEL >= 2
|
||||||
if ( __p != end())
|
_LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
|
||||||
return __p;
|
"unordered_map::try_emplace(const_iterator, key, args...) called with an iterator not"
|
||||||
else
|
" referring to this unordered_map");
|
||||||
return emplace_hint(__h,
|
#endif
|
||||||
_VSTD::piecewise_construct, _VSTD::forward_as_tuple(_VSTD::move(__k)),
|
return try_emplace(_VSTD::move(__k), _VSTD::forward<_Args>(__args)...).first;
|
||||||
_VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class _Vp>
|
template <class _Vp>
|
||||||
_LIBCPP_INLINE_VISIBILITY
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
pair<iterator, bool> insert_or_assign(const key_type& __k, _Vp&& __v)
|
pair<iterator, bool> insert_or_assign(const key_type& __k, _Vp&& __v)
|
||||||
{
|
{
|
||||||
iterator __p = __table_.find(__k);
|
pair<iterator, bool> __res = __table_.__emplace_unique_key_args(__k,
|
||||||
if ( __p != end())
|
__k, _VSTD::forward<_Vp>(__v));
|
||||||
{
|
if (!__res.second) {
|
||||||
__p->second = _VSTD::move(__v);
|
__res.first->second = _VSTD::forward<_Vp>(__v);
|
||||||
return _VSTD::make_pair(__p, false);
|
|
||||||
}
|
}
|
||||||
return _VSTD::make_pair(emplace_hint(__p, __k, _VSTD::forward<_Vp>(__v)), true);
|
return __res;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class _Vp>
|
template <class _Vp>
|
||||||
_LIBCPP_INLINE_VISIBILITY
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
pair<iterator, bool> insert_or_assign(key_type&& __k, _Vp&& __v)
|
pair<iterator, bool> insert_or_assign(key_type&& __k, _Vp&& __v)
|
||||||
{
|
{
|
||||||
iterator __p = __table_.find(__k);
|
pair<iterator, bool> __res = __table_.__emplace_unique_key_args(__k,
|
||||||
if ( __p != end())
|
_VSTD::move(__k), _VSTD::forward<_Vp>(__v));
|
||||||
{
|
if (!__res.second) {
|
||||||
__p->second = _VSTD::move(__v);
|
__res.first->second = _VSTD::forward<_Vp>(__v);
|
||||||
return _VSTD::make_pair(__p, false);
|
|
||||||
}
|
}
|
||||||
return _VSTD::make_pair(emplace_hint(__p, _VSTD::forward<key_type>(__k), _VSTD::forward<_Vp>(__v)), true);
|
return __res;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class _Vp>
|
template <class _Vp>
|
||||||
_LIBCPP_INLINE_VISIBILITY
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
iterator insert_or_assign(const_iterator __h, const key_type& __k, _Vp&& __v)
|
iterator insert_or_assign(const_iterator __h, const key_type& __k, _Vp&& __v)
|
||||||
{
|
{
|
||||||
iterator __p = __table_.find(__k);
|
return insert_or_assign(__k, _VSTD::forward<_Vp>(__v)).first;
|
||||||
if ( __p != end())
|
|
||||||
{
|
|
||||||
__p->second = _VSTD::move(__v);
|
|
||||||
return __p;
|
|
||||||
}
|
|
||||||
return emplace_hint(__h, __k, _VSTD::forward<_Vp>(__v));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class _Vp>
|
template <class _Vp>
|
||||||
_LIBCPP_INLINE_VISIBILITY
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
iterator insert_or_assign(const_iterator __h, key_type&& __k, _Vp&& __v)
|
iterator insert_or_assign(const_iterator __h, key_type&& __k, _Vp&& __v)
|
||||||
{
|
{
|
||||||
iterator __p = __table_.find(__k);
|
return insert_or_assign(_VSTD::move(__k), _VSTD::forward<_Vp>(__v)).first;
|
||||||
if ( __p != end())
|
|
||||||
{
|
|
||||||
__p->second = _VSTD::move(__v);
|
|
||||||
return __p;
|
|
||||||
}
|
|
||||||
return emplace_hint(__h, _VSTD::forward<key_type>(__k), _VSTD::forward<_Vp>(__v));
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
_LIBCPP_INLINE_VISIBILITY
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
|
|||||||
@@ -189,7 +189,7 @@
|
|||||||
<tr><td><a href="http://cplusplus.github.io/LWG/lwg-defects.html#2447">2447</a></td><td>Allocators and <tt>volatile</tt>-qualified value types</td><td>Kona</td><td>Complete</td></tr>
|
<tr><td><a href="http://cplusplus.github.io/LWG/lwg-defects.html#2447">2447</a></td><td>Allocators and <tt>volatile</tt>-qualified value types</td><td>Kona</td><td>Complete</td></tr>
|
||||||
<tr><td><a href="http://cplusplus.github.io/LWG/lwg-defects.html#2462">2462</a></td><td><tt>std::ios_base::failure</tt> is overspecified</td><td>Kona</td><td>Complete</td></tr>
|
<tr><td><a href="http://cplusplus.github.io/LWG/lwg-defects.html#2462">2462</a></td><td><tt>std::ios_base::failure</tt> is overspecified</td><td>Kona</td><td>Complete</td></tr>
|
||||||
<tr><td><a href="http://cplusplus.github.io/LWG/lwg-defects.html#2466">2466</a></td><td><tt>allocator_traits::max_size()</tt> default behavior is incorrect</td><td>Kona</td><td>Complete</td></tr>
|
<tr><td><a href="http://cplusplus.github.io/LWG/lwg-defects.html#2466">2466</a></td><td><tt>allocator_traits::max_size()</tt> default behavior is incorrect</td><td>Kona</td><td>Complete</td></tr>
|
||||||
<tr><td><a href="http://cplusplus.github.io/LWG/lwg-defects.html#2469">2469</a></td><td>Wrong specification of Requires clause of <tt>operator[]</tt> for <tt>map</tt> and <tt>unordered_map</tt></td><td>Kona</td><td></td></tr>
|
<tr><td><a href="http://cplusplus.github.io/LWG/lwg-defects.html#2469">2469</a></td><td>Wrong specification of Requires clause of <tt>operator[]</tt> for <tt>map</tt> and <tt>unordered_map</tt></td><td>Kona</td><td>Complete</td></tr>
|
||||||
<tr><td><a href="http://cplusplus.github.io/LWG/lwg-defects.html#2473">2473</a></td><td><tt>basic_filebuf</tt>'s relation to C <tt>FILE</tt> semantics</td><td>Kona</td><td>Complete</td></tr>
|
<tr><td><a href="http://cplusplus.github.io/LWG/lwg-defects.html#2473">2473</a></td><td><tt>basic_filebuf</tt>'s relation to C <tt>FILE</tt> semantics</td><td>Kona</td><td>Complete</td></tr>
|
||||||
<tr><td><a href="http://cplusplus.github.io/LWG/lwg-defects.html#2476">2476</a></td><td><tt>scoped_allocator_adaptor</tt> is not assignable</td><td>Kona</td><td>Complete</td></tr>
|
<tr><td><a href="http://cplusplus.github.io/LWG/lwg-defects.html#2476">2476</a></td><td><tt>scoped_allocator_adaptor</tt> is not assignable</td><td>Kona</td><td>Complete</td></tr>
|
||||||
<tr><td><a href="http://cplusplus.github.io/LWG/lwg-defects.html#2477">2477</a></td><td>Inconsistency of wordings in <tt>std::vector::erase()</tt> and <tt>std::deque::erase()</tt></td><td>Kona</td><td>Complete</td></tr>
|
<tr><td><a href="http://cplusplus.github.io/LWG/lwg-defects.html#2477">2477</a></td><td>Inconsistency of wordings in <tt>std::vector::erase()</tt> and <tt>std::deque::erase()</tt></td><td>Kona</td><td>Complete</td></tr>
|
||||||
|
|||||||
Reference in New Issue
Block a user