)>
_LIBCPP_HIDE_FROM_ABI
constexpr _Tp* construct_at(_Tp* __location, _Args&& ...__args) {
- _LIBCPP_ASSERT(__location, "null pointer given to construct_at");
+ _LIBCPP_ASSERT(__location != nullptr, "null pointer given to construct_at");
return ::new (_VSTD::__voidify(*__location)) _Tp(_VSTD::forward<_Args>(__args)...);
}
template <class _Tp, typename enable_if<!is_array<_Tp>::value, int>::type = 0>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
void __destroy_at(_Tp* __loc) {
- _LIBCPP_ASSERT(__loc, "null pointer given to destroy_at");
+ _LIBCPP_ASSERT(__loc != nullptr, "null pointer given to destroy_at");
__loc->~_Tp();
}
template <class _Tp, typename enable_if<is_array<_Tp>::value, int>::type = 0>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
void __destroy_at(_Tp* __loc) {
- _LIBCPP_ASSERT(__loc, "null pointer given to destroy_at");
+ _LIBCPP_ASSERT(__loc != nullptr, "null pointer given to destroy_at");
_VSTD::__destroy(_VSTD::begin(*__loc), _VSTD::end(*__loc));
}
#endif
}
}
+template <class _Iterator>
+_LIBCPP_HIDE_FROM_ABI
+bool __iterator_in_range(_Iterator __first, _Iterator __last, _Iterator __it) {
+ for (_Iterator __p = __first; __p != __last; ++__p) {
+ if (__p == __it) {
+ return true;
+ }
+ }
+ return false;
+}
+
template <class _Tp, class _Alloc>
void
list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __f, const_iterator __l)
"list::splice(iterator, list, iterator, iterator) called with second iterator not referring to the list argument");
_LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__l)) == _VSTD::addressof(__c),
"list::splice(iterator, list, iterator, iterator) called with third iterator not referring to the list argument");
+ _LIBCPP_DEBUG_ASSERT(this != std::addressof(__c) || !std::__iterator_in_range(__f, __l, __p),
+ "list::splice(iterator, list, iterator, iterator)"
+ " called with the first iterator within the range of the second and third iterators");
-#if _LIBCPP_DEBUG_LEVEL == 2
- if (this == _VSTD::addressof(__c))
- {
- for (const_iterator __i = __f; __i != __l; ++__i)
- _LIBCPP_DEBUG_ASSERT(__i != __p,
- "list::splice(iterator, list, iterator, iterator)"
- " called with the first iterator within the range of the second and third iterators");
- }
-#endif
if (__f != __l)
{
__link_pointer __first = __f.__ptr_;
pair<iterator, bool> emplace(_Args&&... __args)
{return __table_.__emplace_unique(_VSTD::forward<_Args>(__args)...);}
template <class... _Args>
- _LIBCPP_INLINE_VISIBILITY
-#if _LIBCPP_DEBUG_LEVEL == 2
- iterator emplace_hint(const_iterator __p, _Args&&... __args)
- {
- _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__p)) == this,
- "unordered_set::emplace_hint(const_iterator, args...) called with an iterator not"
- " referring to this unordered_set");
- return __table_.__emplace_unique(_VSTD::forward<_Args>(__args)...).first;
- }
-#else
- iterator emplace_hint(const_iterator, _Args&&... __args)
- {return __table_.__emplace_unique(_VSTD::forward<_Args>(__args)...).first;}
-#endif
+ _LIBCPP_INLINE_VISIBILITY
+ iterator emplace_hint(const_iterator __p, _Args&&... __args) {
+ _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(std::addressof(__p)) == this,
+ "unordered_set::emplace_hint(const_iterator, args...) called with an iterator not"
+ " referring to this unordered_set");
+ (void)__p;
+ return __table_.__emplace_unique(std::forward<_Args>(__args)...).first;
+ }
_LIBCPP_INLINE_VISIBILITY
pair<iterator, bool> insert(value_type&& __x)
{return __table_.__insert_unique(_VSTD::move(__x));}
_LIBCPP_INLINE_VISIBILITY
-#if _LIBCPP_DEBUG_LEVEL == 2
- iterator insert(const_iterator __p, value_type&& __x)
- {
- _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__p)) == this,
- "unordered_set::insert(const_iterator, value_type&&) called with an iterator not"
- " referring to this unordered_set");
- return insert(_VSTD::move(__x)).first;
- }
-#else
- iterator insert(const_iterator, value_type&& __x)
- {return insert(_VSTD::move(__x)).first;}
-#endif
+ iterator insert(const_iterator __p, value_type&& __x) {
+ _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(std::addressof(__p)) == this,
+ "unordered_set::insert(const_iterator, value_type&&) called with an iterator not"
+ " referring to this unordered_set");
+ (void)__p;
+ return insert(std::move(__x)).first;
+ }
+
_LIBCPP_INLINE_VISIBILITY
void insert(initializer_list<value_type> __il)
{insert(__il.begin(), __il.end());}
{return __table_.__insert_unique(__x);}
_LIBCPP_INLINE_VISIBILITY
-#if _LIBCPP_DEBUG_LEVEL == 2
- iterator insert(const_iterator __p, const value_type& __x)
- {
- _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__p)) == this,
- "unordered_set::insert(const_iterator, const value_type&) called with an iterator not"
- " referring to this unordered_set");
- return insert(__x).first;
- }
-#else
- iterator insert(const_iterator, const value_type& __x)
- {return insert(__x).first;}
-#endif
+ iterator insert(const_iterator __p, const value_type& __x) {
+ _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(std::addressof(__p)) == this,
+ "unordered_set::insert(const_iterator, const value_type&) called with an iterator not"
+ " referring to this unordered_set");
+ (void)__p;
+ return insert(__x).first;
+ }
template <class _InputIterator>
_LIBCPP_INLINE_VISIBILITY
void insert(_InputIterator __first, _InputIterator __last);