1 //===----------------------------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
11 // allocator_type get_allocator() const; // constexpr since C++20
16 #include "test_macros.h"
17 #include "test_allocator.h"
18 #include "min_allocator.h"
21 TEST_CONSTEXPR_CXX20
void test(const S
& s
, const typename
S::allocator_type
& a
) {
22 assert(s
.get_allocator() == a
);
25 template <class Alloc
>
26 TEST_CONSTEXPR_CXX20
void test_string(const Alloc
& a
) {
27 using S
= std::basic_string
<char, std::char_traits
<char>, Alloc
>;
29 test(S("abcde", Alloc(a
)), Alloc(a
));
30 test(S("abcdefghij", Alloc(a
)), Alloc(a
));
31 test(S("abcdefghijklmnopqrst", Alloc(a
)), Alloc(a
));
34 TEST_CONSTEXPR_CXX20
bool test() {
35 test_string(std::allocator
<char>());
36 test_string(test_allocator
<char>());
37 test_string(test_allocator
<char>(1));
38 test_string(test_allocator
<char>(2));
39 test_string(test_allocator
<char>(3));
40 #if TEST_STD_VER >= 11
41 test_string(min_allocator
<char>());
47 int main(int, char**) {
50 static_assert(test());