Mark LWG issue 2469 as done. Also simplify try_emplace and insert_or_assign implementations in unordered_map

llvm-svn: 266591
This commit is contained in:
Eric Fiselier 2016-04-18 06:51:33 +00:00
parent 2152fd7682
commit 87c4104d30
2 changed files with 32 additions and 64 deletions

View File

@ -984,117 +984,85 @@ public:
#endif // _LIBCPP_CXX03_LANG
#if _LIBCPP_STD_VER > 14
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
#ifndef _LIBCPP_HAS_NO_VARIADICS
template <class... _Args>
_LIBCPP_INLINE_VISIBILITY
pair<iterator, bool> try_emplace(const key_type& __k, _Args&&... __args)
{
iterator __p = __table_.find(__k);
if ( __p != end())
return _VSTD::make_pair(__p, false);
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);
return __table_.__emplace_unique_key_args(__k, _VSTD::piecewise_construct,
_VSTD::forward_as_tuple(__k),
_VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...));
}
template <class... _Args>
_LIBCPP_INLINE_VISIBILITY
pair<iterator, bool> try_emplace(key_type&& __k, _Args&&... __args)
{
iterator __p = __table_.find(__k);
if ( __p != end())
return _VSTD::make_pair(__p, false);
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);
return __table_.__emplace_unique_key_args(__k, _VSTD::piecewise_construct,
_VSTD::forward_as_tuple(_VSTD::move(__k)),
_VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...));
}
template <class... _Args>
_LIBCPP_INLINE_VISIBILITY
iterator try_emplace(const_iterator __h, const key_type& __k, _Args&&... __args)
{
iterator __p = __table_.find(__k);
if ( __p != end())
return __p;
else
return emplace_hint(__h,
_VSTD::piecewise_construct, _VSTD::forward_as_tuple(__k),
_VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...));
#if _LIBCPP_DEBUG_LEVEL >= 2
_LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
"unordered_map::try_emplace(const_iterator, key, args...) called with an iterator not"
" referring to this unordered_map");
#endif
return try_emplace(__k, _VSTD::forward<_Args>(__args)...).first;
}
template <class... _Args>
_LIBCPP_INLINE_VISIBILITY
iterator try_emplace(const_iterator __h, key_type&& __k, _Args&&... __args)
{
iterator __p = __table_.find(__k);
if ( __p != end())
return __p;
else
return emplace_hint(__h,
_VSTD::piecewise_construct, _VSTD::forward_as_tuple(_VSTD::move(__k)),
_VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...));
#if _LIBCPP_DEBUG_LEVEL >= 2
_LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
"unordered_map::try_emplace(const_iterator, key, args...) called with an iterator not"
" referring to this unordered_map");
#endif
return try_emplace(_VSTD::move(__k), _VSTD::forward<_Args>(__args)...).first;
}
template <class _Vp>
_LIBCPP_INLINE_VISIBILITY
pair<iterator, bool> insert_or_assign(const key_type& __k, _Vp&& __v)
{
iterator __p = __table_.find(__k);
if ( __p != end())
{
__p->second = _VSTD::move(__v);
return _VSTD::make_pair(__p, false);
pair<iterator, bool> __res = __table_.__emplace_unique_key_args(__k,
__k, _VSTD::forward<_Vp>(__v));
if (!__res.second) {
__res.first->second = _VSTD::forward<_Vp>(__v);
}
return _VSTD::make_pair(emplace_hint(__p, __k, _VSTD::forward<_Vp>(__v)), true);
return __res;
}
template <class _Vp>
_LIBCPP_INLINE_VISIBILITY
pair<iterator, bool> insert_or_assign(key_type&& __k, _Vp&& __v)
{
iterator __p = __table_.find(__k);
if ( __p != end())
{
__p->second = _VSTD::move(__v);
return _VSTD::make_pair(__p, false);
pair<iterator, bool> __res = __table_.__emplace_unique_key_args(__k,
_VSTD::move(__k), _VSTD::forward<_Vp>(__v));
if (!__res.second) {
__res.first->second = _VSTD::forward<_Vp>(__v);
}
return _VSTD::make_pair(emplace_hint(__p, _VSTD::forward<key_type>(__k), _VSTD::forward<_Vp>(__v)), true);
return __res;
}
template <class _Vp>
_LIBCPP_INLINE_VISIBILITY
iterator insert_or_assign(const_iterator __h, const key_type& __k, _Vp&& __v)
{
iterator __p = __table_.find(__k);
if ( __p != end())
{
__p->second = _VSTD::move(__v);
return __p;
}
return emplace_hint(__h, __k, _VSTD::forward<_Vp>(__v));
return insert_or_assign(__k, _VSTD::forward<_Vp>(__v)).first;
}
template <class _Vp>
_LIBCPP_INLINE_VISIBILITY
iterator insert_or_assign(const_iterator __h, key_type&& __k, _Vp&& __v)
{
iterator __p = __table_.find(__k);
if ( __p != end())
{
__p->second = _VSTD::move(__v);
return __p;
}
return emplace_hint(__h, _VSTD::forward<key_type>(__k), _VSTD::forward<_Vp>(__v));
return insert_or_assign(_VSTD::move(__k), _VSTD::forward<_Vp>(__v)).first;
}
#endif
#endif
#endif
_LIBCPP_INLINE_VISIBILITY

View File

@ -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#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#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#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>