[lld][WebAssembly] Introduce Ctx::arg
[llvm-project.git] / libcxx / test / std / containers / sequences / deque / deque.modifiers / pop_back.invalidation.pass.cpp
blob3071d00a9dbffb23a0c7d36c3badc0647b3b8c73
1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 // <deque>
11 // void pop_back()
13 // Erasing items from the beginning or the end of a deque shall not invalidate iterators
14 // to items that were not erased.
16 #include "asan_testing.h"
17 #include <deque>
18 #include <cassert>
20 #include "test_macros.h"
22 template <typename C>
23 void test(C c)
25 typename C::iterator it1 = c.begin();
26 typename C::iterator it2 = c.end() - 2;
28 c.pop_back();
30 typename C::iterator it3 = c.begin();
31 typename C::iterator it4 = c.end() - 1;
32 assert( it1 == it3);
33 assert( *it1 == *it3);
34 assert(&*it1 == &*it3);
35 assert( it2 == it4);
36 assert( *it2 == *it4);
37 assert(&*it2 == &*it4);
38 LIBCPP_ASSERT(is_double_ended_contiguous_container_asan_correct(c));
41 int main(int, char**)
43 std::deque<int> queue;
44 for (int i = 0; i < 4098; ++i)
45 queue.push_back(i);
47 while (queue.size() > 1)
49 test(queue);
50 queue.pop_back();
51 LIBCPP_ASSERT(is_double_ended_contiguous_container_asan_correct(queue));
54 return 0;