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 // size_type size() const; // 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(const S& s, typename S::size_type c) 24 { 25 assert(s.size() == c); 26 } 27 28 TEST_CONSTEXPR_CXX20 bool test() { 29 { 30 typedef std::string S; 31 test(S(), 0); 32 test(S("123"), 3); 33 test(S("12345678901234567890123456789012345678901234567890"), 50); 34 } 35 #if TEST_STD_VER >= 11 36 { 37 typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; 38 test(S(), 0); 39 test(S("123"), 3); 40 test(S("12345678901234567890123456789012345678901234567890"), 50); 41 } 42 #endif 43 44 return true; 45 } 46 47 int main(int, char**) 48 { 49 test(); 50 #if TEST_STD_VER > 17 51 static_assert(test()); 52 #endif 53 54 return 0; 55 } 56