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 // void shrink_to_fit(); // constexpr since C++20
16 #include "test_macros.h"
17 #include "min_allocator.h"
20 TEST_CONSTEXPR_CXX20
void test(S s
) {
21 typename
S::size_type old_cap
= s
.capacity();
24 LIBCPP_ASSERT(s
.__invariants());
26 assert(s
.capacity() <= old_cap
);
27 assert(s
.capacity() >= s
.size());
31 TEST_CONSTEXPR_CXX20
void test_string() {
44 TEST_CONSTEXPR_CXX20
bool test() {
45 test_string
<std::string
>();
46 #if TEST_STD_VER >= 11
47 test_string
<std::basic_string
<char, std::char_traits
<char>, min_allocator
<char>>>();
53 int main(int, char**) {
56 static_assert(test());