forked from OSchip/llvm-project
parent
830f0b8d9f
commit
b0e4c9d01b
|
@ -1292,7 +1292,11 @@ list<_Tp, _Alloc>::insert(const_iterator __p, const value_type& __x)
|
|||
__node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), __x);
|
||||
__link_nodes(const_cast<__node&>(*__p.__ptr_), *__hold, *__hold);
|
||||
++base::__sz();
|
||||
#if _LIBCPP_DEBUG_LEVEL >= 2
|
||||
return iterator(__hold.release(), this);
|
||||
#else
|
||||
return iterator(__hold.release());
|
||||
#endif
|
||||
}
|
||||
|
||||
template <class _Tp, class _Alloc>
|
||||
|
@ -1518,6 +1522,11 @@ template <class... _Args>
|
|||
typename list<_Tp, _Alloc>::iterator
|
||||
list<_Tp, _Alloc>::emplace(const_iterator __p, _Args&&... __args)
|
||||
{
|
||||
#if _LIBCPP_DEBUG_LEVEL >= 2
|
||||
_LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
|
||||
"list::emplace(iterator, args...) called with an iterator not"
|
||||
" referring to this list");
|
||||
#endif
|
||||
__node_allocator& __na = base::__node_alloc();
|
||||
typedef __allocator_destructor<__node_allocator> _Dp;
|
||||
unique_ptr<__node, _Dp> __hold(__node_alloc_traits::allocate(__na, 1), _Dp(__na, 1));
|
||||
|
@ -1624,6 +1633,8 @@ list<_Tp, _Alloc>::erase(const_iterator __p)
|
|||
"list::erase(iterator) called with an iterator not"
|
||||
" referring to this list");
|
||||
#endif
|
||||
_LIBCPP_ASSERT(__p != end(),
|
||||
"list::erase(iterator) called with a non-dereferenceable iterator");
|
||||
__node_allocator& __na = base::__node_alloc();
|
||||
__node& __n = const_cast<__node&>(*__p.__ptr_);
|
||||
__node_pointer __r = __n.__next_;
|
||||
|
|
|
@ -11,6 +11,10 @@
|
|||
|
||||
// template <class... Args> void emplace(const_iterator p, Args&&... args);
|
||||
|
||||
#if _LIBCPP_DEBUG2 >= 1
|
||||
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
|
||||
#endif
|
||||
|
||||
#include <list>
|
||||
#include <cassert>
|
||||
|
||||
|
@ -44,4 +48,12 @@ int main()
|
|||
assert(c.back().geti() == 3);
|
||||
assert(c.back().getd() == 4.5);
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
#if _LIBCPP_DEBUG2 >= 1
|
||||
{
|
||||
std::list<A> c1;
|
||||
std::list<A> c2;
|
||||
std::list<A>::iterator i = c1.emplace(c2.cbegin(), 2, 3.5);
|
||||
assert(false);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -12,9 +12,14 @@
|
|||
// template <InputIterator Iter>
|
||||
// iterator insert(const_iterator position, Iter first, Iter last);
|
||||
|
||||
#if _LIBCPP_DEBUG2 >= 1
|
||||
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
|
||||
#endif
|
||||
|
||||
#include <list>
|
||||
#include <cstdlib>
|
||||
#include <cassert>
|
||||
#include "test_iterators.h"
|
||||
|
||||
int throw_next = 0xFFFF;
|
||||
int count = 0;
|
||||
|
@ -36,6 +41,7 @@ void operator delete(void* p) throw()
|
|||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
int a1[] = {1, 2, 3};
|
||||
std::list<int> l1;
|
||||
std::list<int>::iterator i = l1.insert(l1.begin(), a1, a1+3);
|
||||
|
@ -90,4 +96,17 @@ int main()
|
|||
assert(*i == 6);
|
||||
++i;
|
||||
assert(*i == 3);
|
||||
}
|
||||
#if _LIBCPP_DEBUG2 >= 1
|
||||
{
|
||||
throw_next = 0xFFFF;
|
||||
std::list<int> v(100);
|
||||
std::list<int> v2(100);
|
||||
int a[] = {1, 2, 3, 4, 5};
|
||||
const int N = sizeof(a)/sizeof(a[0]);
|
||||
std::list<int>::iterator i = v.insert(next(v2.cbegin(), 10), input_iterator<const int*>(a),
|
||||
input_iterator<const int*>(a+N));
|
||||
assert(false);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -11,6 +11,10 @@
|
|||
|
||||
// iterator insert(const_iterator position, value_type&& x);
|
||||
|
||||
#if _LIBCPP_DEBUG2 >= 1
|
||||
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
|
||||
#endif
|
||||
|
||||
#include <list>
|
||||
#include <cassert>
|
||||
|
||||
|
@ -28,4 +32,12 @@ int main()
|
|||
assert(l1.front() == MoveOnly(2));
|
||||
assert(l1.back() == MoveOnly(1));
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
#if _LIBCPP_DEBUG2 >= 1
|
||||
{
|
||||
std::list<int> v1(3);
|
||||
std::list<int> v2(3);
|
||||
v1.insert(v2.begin(), 4);
|
||||
assert(false);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -11,6 +11,10 @@
|
|||
|
||||
// iterator insert(const_iterator position, size_type n, const value_type& x);
|
||||
|
||||
#if _LIBCPP_DEBUG2 >= 1
|
||||
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
|
||||
#endif
|
||||
|
||||
#include <list>
|
||||
#include <cstdlib>
|
||||
#include <cassert>
|
||||
|
@ -54,4 +58,12 @@ int main()
|
|||
throw_next = 0xFFFF;
|
||||
assert(save_count == count);
|
||||
assert(l1 == std::list<int>(a2, a2+8));
|
||||
#if _LIBCPP_DEBUG2 >= 1
|
||||
{
|
||||
std::list<int> c1(100);
|
||||
std::list<int> c2;
|
||||
std::list<int>::iterator i = c1.insert(next(c2.cbegin(), 10), 5, 1);
|
||||
assert(false);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -11,6 +11,10 @@
|
|||
|
||||
// iterator insert(const_iterator position, const value_type& x);
|
||||
|
||||
#if _LIBCPP_DEBUG2 >= 1
|
||||
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
|
||||
#endif
|
||||
|
||||
#include <list>
|
||||
#include <cstdlib>
|
||||
#include <cassert>
|
||||
|
@ -56,4 +60,13 @@ int main()
|
|||
throw_next = 0xFFFF;
|
||||
assert(save_count == count);
|
||||
assert(l1 == std::list<int>(a2, a2+4));
|
||||
#if _LIBCPP_DEBUG2 >= 1
|
||||
{
|
||||
std::list<int> v1(3);
|
||||
std::list<int> v2(3);
|
||||
int i = 4;
|
||||
v1.insert(v2.begin(), i);
|
||||
assert(false);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -11,6 +11,10 @@
|
|||
|
||||
// void pop_back();
|
||||
|
||||
#if _LIBCPP_DEBUG2 >= 1
|
||||
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
|
||||
#endif
|
||||
|
||||
#include <list>
|
||||
#include <cassert>
|
||||
|
||||
|
@ -24,4 +28,8 @@ int main()
|
|||
assert(c == std::list<int>(a, a+1));
|
||||
c.pop_back();
|
||||
assert(c.empty());
|
||||
#if _LIBCPP_DEBUG2 >= 1
|
||||
c.pop_back();
|
||||
assert(false);
|
||||
#endif
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue