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// <vector>
10
11// class vector
12
13// allocator_type get_allocator() const
14
15#include <vector>
16#include <cassert>
17
18#include "test_allocator.h"
19#include "test_macros.h"
20
21TEST_CONSTEXPR_CXX20 bool test() {
22 {
23 std::allocator<int> alloc;
24 const std::vector<int> v(alloc);
25 assert(v.get_allocator() == alloc);
26 }
27 {
28 other_allocator<int> alloc(1);
29 const std::vector<int, other_allocator<int> > v(alloc);
30 assert(v.get_allocator() == alloc);
31 }
32
33 return true;
34}
35
36int main(int, char**) {
37 test();
38#if TEST_STD_VER > 17
39 static_assert(test());
40#endif
41
42 return 0;
43}
44

source code of libcxx/test/std/containers/sequences/vector/get_allocator.pass.cpp