| 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 | // <forward_list> |
| 10 | |
| 11 | // explicit forward_list(const allocator_type& a); // constexpr since C++26 |
| 12 | |
| 13 | #include <forward_list> |
| 14 | #include <cassert> |
| 15 | |
| 16 | #include "test_macros.h" |
| 17 | #include "test_allocator.h" |
| 18 | #include "../../../NotConstructible.h" |
| 19 | #include "min_allocator.h" |
| 20 | |
| 21 | TEST_CONSTEXPR_CXX26 bool test() { |
| 22 | { |
| 23 | typedef test_allocator<NotConstructible> A; |
| 24 | typedef A::value_type T; |
| 25 | typedef std::forward_list<T, A> C; |
| 26 | C c(A(12)); |
| 27 | assert(c.get_allocator() == A(12)); |
| 28 | assert(c.empty()); |
| 29 | } |
| 30 | #if TEST_STD_VER >= 11 |
| 31 | { |
| 32 | typedef min_allocator<NotConstructible> A; |
| 33 | typedef A::value_type T; |
| 34 | typedef std::forward_list<T, A> C; |
| 35 | C c(A{}); |
| 36 | assert(c.get_allocator() == A()); |
| 37 | assert(c.empty()); |
| 38 | } |
| 39 | { |
| 40 | typedef explicit_allocator<NotConstructible> A; |
| 41 | typedef A::value_type T; |
| 42 | typedef std::forward_list<T, A> C; |
| 43 | C c(A{}); |
| 44 | assert(c.get_allocator() == A()); |
| 45 | assert(c.empty()); |
| 46 | } |
| 47 | #endif |
| 48 | |
| 49 | return true; |
| 50 | } |
| 51 | |
| 52 | int main(int, char**) { |
| 53 | assert(test()); |
| 54 | #if TEST_STD_VER >= 26 |
| 55 | static_assert(test()); |
| 56 | #endif |
| 57 | |
| 58 | return 0; |
| 59 | } |
| 60 | |