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 // XFAIL: LIBCXX-AIX-FIXME 10 11 // <string> 12 13 // void clear(); // constexpr since C++20 14 15 #include <string> 16 #include <cassert> 17 18 #include "test_macros.h" 19 #include "min_allocator.h" 20 21 template <class S> 22 TEST_CONSTEXPR_CXX20 void 23 test(S s) 24 { 25 s.clear(); 26 assert(s.size() == 0); 27 } 28 29 TEST_CONSTEXPR_CXX20 bool test() { 30 { 31 typedef std::string S; 32 S s; 33 test(s); 34 35 s.assign(10, 'a'); 36 s.erase(5); 37 test(s); 38 39 s.assign(100, 'a'); 40 s.erase(50); 41 test(s); 42 } 43 #if TEST_STD_VER >= 11 44 { 45 typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; 46 S s; 47 test(s); 48 49 s.assign(10, 'a'); 50 s.erase(5); 51 test(s); 52 53 s.assign(100, 'a'); 54 s.erase(50); 55 test(s); 56 } 57 #endif 58 59 return true; 60 } 61 62 int main(int, char**) 63 { 64 test(); 65 #if TEST_STD_VER > 17 66 static_assert(test()); 67 #endif 68 69 return 0; 70 } 71