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 test(const C& x, const typename C::allocator_type& a) {
23 C c(x, a);
24 assert(c == x);
25 assert(c.get_allocator() == a);
26 LIBCPP_ASSERT(is_double_ended_contiguous_container_asan_correct(c));
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(std::deque<int, test_allocator<int> >(ab, an, test_allocator<int>(3)), test_allocator<int>(4));
34 }
35 {
36 int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
37 int* an = ab + sizeof(ab) / sizeof(ab[0]);
38 test(std::deque<int, other_allocator<int> >(ab, an, other_allocator<int>(3)), other_allocator<int>(4));
39 }
40#if TEST_STD_VER >= 11
41 {
42 int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
43 int* an = ab + sizeof(ab) / sizeof(ab[0]);
44 test(std::deque<int, min_allocator<int> >(ab, an, min_allocator<int>()), min_allocator<int>());
45 }
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, safe_allocator<int> >(ab, an, safe_allocator<int>()), safe_allocator<int>());
50 }
51#endif
52
53 return 0;
54}
55

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