@@ -1487,13 +1487,15 @@ void deque<_Tp, _Allocator>::shrink_to_fit() _NOEXCEPT {
1487
1487
1488
1488
template <class _Tp , class _Allocator >
1489
1489
inline typename deque<_Tp, _Allocator>::reference deque<_Tp, _Allocator>::operator [](size_type __i) _NOEXCEPT {
1490
+ _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS (__i < size (), " deque::operator[] index out of bounds" );
1490
1491
size_type __p = __start_ + __i;
1491
1492
return *(*(__map_.begin () + __p / __block_size) + __p % __block_size);
1492
1493
}
1493
1494
1494
1495
template <class _Tp , class _Allocator >
1495
1496
inline typename deque<_Tp, _Allocator>::const_reference
1496
1497
deque<_Tp, _Allocator>::operator [](size_type __i) const _NOEXCEPT {
1498
+ _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS (__i < size (), " deque::operator[] index out of bounds" );
1497
1499
size_type __p = __start_ + __i;
1498
1500
return *(*(__map_.begin () + __p / __block_size) + __p % __block_size);
1499
1501
}
@@ -1516,22 +1518,26 @@ inline typename deque<_Tp, _Allocator>::const_reference deque<_Tp, _Allocator>::
1516
1518
1517
1519
template <class _Tp , class _Allocator >
1518
1520
inline typename deque<_Tp, _Allocator>::reference deque<_Tp, _Allocator>::front() _NOEXCEPT {
1521
+ _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS (!empty (), " deque::front called on an empty deque" );
1519
1522
return *(*(__map_.begin () + __start_ / __block_size) + __start_ % __block_size);
1520
1523
}
1521
1524
1522
1525
template <class _Tp , class _Allocator >
1523
1526
inline typename deque<_Tp, _Allocator>::const_reference deque<_Tp, _Allocator>::front() const _NOEXCEPT {
1527
+ _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS (!empty (), " deque::front called on an empty deque" );
1524
1528
return *(*(__map_.begin () + __start_ / __block_size) + __start_ % __block_size);
1525
1529
}
1526
1530
1527
1531
template <class _Tp , class _Allocator >
1528
1532
inline typename deque<_Tp, _Allocator>::reference deque<_Tp, _Allocator>::back() _NOEXCEPT {
1533
+ _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS (!empty (), " deque::back called on an empty deque" );
1529
1534
size_type __p = size () + __start_ - 1 ;
1530
1535
return *(*(__map_.begin () + __p / __block_size) + __p % __block_size);
1531
1536
}
1532
1537
1533
1538
template <class _Tp , class _Allocator >
1534
1539
inline typename deque<_Tp, _Allocator>::const_reference deque<_Tp, _Allocator>::back() const _NOEXCEPT {
1540
+ _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS (!empty (), " deque::back called on an empty deque" );
1535
1541
size_type __p = size () + __start_ - 1 ;
1536
1542
return *(*(__map_.begin () + __p / __block_size) + __p % __block_size);
1537
1543
}
@@ -2255,6 +2261,7 @@ void deque<_Tp, _Allocator>::__add_back_capacity(size_type __n) {
2255
2261
2256
2262
template <class _Tp , class _Allocator >
2257
2263
void deque<_Tp, _Allocator>::pop_front () {
2264
+ _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS (!empty (), " deque::pop_front called on an empty deque" );
2258
2265
size_type __old_sz = size ();
2259
2266
size_type __old_start = __start_;
2260
2267
allocator_type& __a = __alloc ();
@@ -2395,6 +2402,8 @@ void deque<_Tp, _Allocator>::__move_construct_backward_and_check(
2395
2402
2396
2403
template <class _Tp , class _Allocator >
2397
2404
typename deque<_Tp, _Allocator>::iterator deque<_Tp, _Allocator>::erase (const_iterator __f) {
2405
+ _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS (
2406
+ __f != end (), " deque::erase(iterator) called with a non-dereferenceable iterator" );
2398
2407
size_type __old_sz = size ();
2399
2408
size_type __old_start = __start_;
2400
2409
iterator __b = begin ();
@@ -2420,6 +2429,7 @@ typename deque<_Tp, _Allocator>::iterator deque<_Tp, _Allocator>::erase(const_it
2420
2429
2421
2430
template <class _Tp , class _Allocator >
2422
2431
typename deque<_Tp, _Allocator>::iterator deque<_Tp, _Allocator>::erase (const_iterator __f, const_iterator __l) {
2432
+ _LIBCPP_ASSERT_VALID_INPUT_RANGE (__f <= __l, " deque::erase(first, last) called with an invalid range" );
2423
2433
size_type __old_sz = size ();
2424
2434
size_type __old_start = __start_;
2425
2435
difference_type __n = __l - __f;
0 commit comments