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// <stack>
10
11// template <class Alloc>
12// explicit stack(const Alloc& a);
13
14#include <stack>
15#include <cassert>
16
17#include "test_macros.h"
18#include "test_allocator.h"
19
20struct test : private std::stack<int, std::deque<int, test_allocator<int> > > {
21 typedef std::stack<int, std::deque<int, test_allocator<int> > > base;
22
23 explicit test(const test_allocator<int>& a) : base(a) {}
24 test(const container_type& cont, const test_allocator<int>& a) : base(cont, a) {}
25#if TEST_STD_VER >= 11
26 test(container_type&& cont, const test_allocator<int>& a) : base(std::move(cont), a) {}
27 test(test&& q, const test_allocator<int>& a) : base(std::move(q), a) {}
28#endif
29 test_allocator<int> get_allocator() { return c.get_allocator(); }
30};
31
32int main(int, char**) {
33 test q(test_allocator<int>(3));
34 assert(q.get_allocator() == test_allocator<int>(3));
35
36 return 0;
37}
38

source code of libcxx/test/std/containers/container.adaptors/stack/stack.cons.alloc/ctor_alloc.pass.cpp