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& c, const allocator_type& a);
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
23test(const C& x, const typename C::allocator_type& a)
24{
25 C c(x, a);
26 assert(c == x);
27 assert(c.get_allocator() == a);
28 LIBCPP_ASSERT(is_double_ended_contiguous_container_asan_correct(c));
29}
30
31int main(int, char**)
32{
33 {
34 int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
35 int* an = ab + sizeof(ab)/sizeof(ab[0]);
36 test(std::deque<int, test_allocator<int> >(ab, an, test_allocator<int>(3)),
37 test_allocator<int>(4));
38 }
39 {
40 int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
41 int* an = ab + sizeof(ab)/sizeof(ab[0]);
42 test(std::deque<int, other_allocator<int> >(ab, an, other_allocator<int>(3)),
43 other_allocator<int>(4));
44 }
45#if TEST_STD_VER >= 11
46 {
47 int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
48 int* an = ab + sizeof(ab)/sizeof(ab[0]);
49 test(std::deque<int, min_allocator<int> >(ab, an, min_allocator<int>()),
50 min_allocator<int>());
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, safe_allocator<int> >(ab, an, safe_allocator<int>()),
56 safe_allocator<int>());
57 }
58#endif
59
60 return 0;
61}
62

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