| 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 | // UNSUPPORTED: c++03 |
| 10 | |
| 11 | // <vector> |
| 12 | |
| 13 | // vector(initializer_list<value_type> il, const Allocator& a = allocator_type()); |
| 14 | |
| 15 | #include <vector> |
| 16 | #include <cassert> |
| 17 | |
| 18 | #include "test_macros.h" |
| 19 | #include "test_allocator.h" |
| 20 | #include "min_allocator.h" |
| 21 | |
| 22 | TEST_CONSTEXPR_CXX20 bool tests() { |
| 23 | { |
| 24 | std::vector<bool, test_allocator<bool>> d({true, false, false, true}, test_allocator<bool>(3)); |
| 25 | assert(d.get_allocator() == test_allocator<bool>(3)); |
| 26 | assert(d.size() == 4); |
| 27 | assert(d[0] == true); |
| 28 | assert(d[1] == false); |
| 29 | assert(d[2] == false); |
| 30 | assert(d[3] == true); |
| 31 | } |
| 32 | { |
| 33 | std::vector<bool, min_allocator<bool>> d({true, false, false, true}, min_allocator<bool>()); |
| 34 | assert(d.get_allocator() == min_allocator<bool>()); |
| 35 | assert(d.size() == 4); |
| 36 | assert(d[0] == true); |
| 37 | assert(d[1] == false); |
| 38 | assert(d[2] == false); |
| 39 | assert(d[3] == true); |
| 40 | } |
| 41 | |
| 42 | return true; |
| 43 | } |
| 44 | |
| 45 | int main(int, char**) { |
| 46 | tests(); |
| 47 | #if TEST_STD_VER > 17 |
| 48 | static_assert(tests()); |
| 49 | #endif |
| 50 | return 0; |
| 51 | } |
| 52 | |