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//===----------------------------------------------------------------------===//
8
9// <deque>
10
11// deque(const deque&);
12
13#include "asan_testing.h"
14#include <deque>
15#include <cassert>
16
17#include "test_macros.h"
18#include "test_allocator.h"
19#include "min_allocator.h"
20
21template <class C>
22void test(const C& x) {
23 C c(x);
24 assert(c == x);
25 LIBCPP_ASSERT(is_double_ended_contiguous_container_asan_correct(c));
26 LIBCPP_ASSERT(is_double_ended_contiguous_container_asan_correct(x));
27}
28
29int main(int, char**) {
30 {
31 int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
32 int* an = ab + sizeof(ab) / sizeof(ab[0]);
33 test(x: std::deque<int>(ab, an));
34 }
35 {
36 std::deque<int, test_allocator<int> > v(3, 2, test_allocator<int>(5));
37 std::deque<int, test_allocator<int> > v2 = v;
38 assert(v2 == v);
39 assert(v2.get_allocator() == v.get_allocator());
40 LIBCPP_ASSERT(is_double_ended_contiguous_container_asan_correct(v));
41 LIBCPP_ASSERT(is_double_ended_contiguous_container_asan_correct(v2));
42 }
43#if TEST_STD_VER >= 11
44 {
45 std::deque<int, other_allocator<int> > v(3, 2, other_allocator<int>(5));
46 std::deque<int, other_allocator<int> > v2 = v;
47 assert(v2 == v);
48 assert(v2.get_allocator() == other_allocator<int>(-2));
49 LIBCPP_ASSERT(is_double_ended_contiguous_container_asan_correct(v));
50 LIBCPP_ASSERT(is_double_ended_contiguous_container_asan_correct(v2));
51 }
52 {
53 int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
54 int* an = ab + sizeof(ab) / sizeof(ab[0]);
55 test(std::deque<int, min_allocator<int>>(ab, an));
56 }
57 {
58 std::deque<int, min_allocator<int> > v(3, 2, min_allocator<int>());
59 std::deque<int, min_allocator<int> > v2 = v;
60 assert(v2 == v);
61 assert(v2.get_allocator() == v.get_allocator());
62 LIBCPP_ASSERT(is_double_ended_contiguous_container_asan_correct(v));
63 LIBCPP_ASSERT(is_double_ended_contiguous_container_asan_correct(v2));
64 }
65#endif
66
67 return 0;
68}
69

source code of libcxx/test/std/containers/sequences/deque/deque.cons/copy.pass.cpp