[libc++][NFC] Use _LIBCPP_DEBUG_ASSERT in <unordered_map>

Use `_LIBCPP_DEBUG_ASSERT` in <unordered_map>

Reviewed By: ldionne, Mordante, #libc

Spies: libcxx-commits

Differential Revision: https://reviews.llvm.org/D117401
This commit is contained in:
Nikolas Klauser 2022-01-15 19:41:33 +01:00
parent 6322cb4890
commit 275e7d197c
1 changed files with 18 additions and 36 deletions

View File

@ -1186,13 +1186,10 @@ public:
{return __table_.__insert_unique(__x);} {return __table_.__insert_unique(__x);}
iterator insert(const_iterator __p, const value_type& __x) { iterator insert(const_iterator __p, const value_type& __x) {
#if _LIBCPP_DEBUG_LEVEL == 2 _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
_LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this, "unordered_map::insert(const_iterator, const value_type&) called with an iterator not "
"unordered_map::insert(const_iterator, const value_type&) called with an iterator not" "referring to this unordered_map");
" referring to this unordered_map");
#else
((void)__p); ((void)__p);
#endif
return insert(__x).first; return insert(__x).first;
} }
@ -1210,13 +1207,10 @@ public:
{return __table_.__insert_unique(_VSTD::move(__x));} {return __table_.__insert_unique(_VSTD::move(__x));}
iterator insert(const_iterator __p, value_type&& __x) { iterator insert(const_iterator __p, value_type&& __x) {
#if _LIBCPP_DEBUG_LEVEL == 2 _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
_LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this, "unordered_map::insert(const_iterator, const value_type&) called with an iterator not"
"unordered_map::insert(const_iterator, const value_type&) called with an iterator not" " referring to this unordered_map");
" referring to this unordered_map");
#else
((void)__p); ((void)__p);
#endif
return __table_.__insert_unique(_VSTD::move(__x)).first; return __table_.__insert_unique(_VSTD::move(__x)).first;
} }
@ -1231,13 +1225,10 @@ public:
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
iterator insert(const_iterator __p, _Pp&& __x) iterator insert(const_iterator __p, _Pp&& __x)
{ {
#if _LIBCPP_DEBUG_LEVEL == 2 _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
_LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this, "unordered_map::insert(const_iterator, value_type&&) called with an iterator not"
"unordered_map::insert(const_iterator, value_type&&) called with an iterator not" " referring to this unordered_map");
" referring to this unordered_map");
#else
((void)__p); ((void)__p);
#endif
return insert(_VSTD::forward<_Pp>(__x)).first; return insert(_VSTD::forward<_Pp>(__x)).first;
} }
@ -1250,13 +1241,10 @@ public:
template <class... _Args> template <class... _Args>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
iterator emplace_hint(const_iterator __p, _Args&&... __args) { iterator emplace_hint(const_iterator __p, _Args&&... __args) {
#if _LIBCPP_DEBUG_LEVEL == 2 _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
_LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this, "unordered_map::emplace_hint(const_iterator, args...) called with an iterator not"
"unordered_map::emplace_hint(const_iterator, args...) called with an iterator not" " referring to this unordered_map");
" referring to this unordered_map");
#else
((void)__p); ((void)__p);
#endif
return __table_.__emplace_unique(_VSTD::forward<_Args>(__args)...).first; return __table_.__emplace_unique(_VSTD::forward<_Args>(__args)...).first;
} }
@ -1285,13 +1273,10 @@ public:
_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)
{ {
#if _LIBCPP_DEBUG_LEVEL == 2 _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(&__h) == this,
_LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__h) == this, "unordered_map::try_emplace(const_iterator, key, args...) called with an iterator not"
"unordered_map::try_emplace(const_iterator, key, args...) called with an iterator not" " referring to this unordered_map");
" referring to this unordered_map");
#else
((void)__h); ((void)__h);
#endif
return try_emplace(__k, _VSTD::forward<_Args>(__args)...).first; return try_emplace(__k, _VSTD::forward<_Args>(__args)...).first;
} }
@ -1299,13 +1284,10 @@ public:
_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)
{ {
#if _LIBCPP_DEBUG_LEVEL == 2 _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(&__h) == this,
_LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__h) == this, "unordered_map::try_emplace(const_iterator, key, args...) called with an iterator not"
"unordered_map::try_emplace(const_iterator, key, args...) called with an iterator not" " referring to this unordered_map");
" referring to this unordered_map");
#else
((void)__h); ((void)__h);
#endif
return try_emplace(_VSTD::move(__k), _VSTD::forward<_Args>(__args)...).first; return try_emplace(_VSTD::move(__k), _VSTD::forward<_Args>(__args)...).first;
} }