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 // UNSUPPORTED: c++03 10 11 // XFAIL: LIBCXX-AIX-FIXME 12 13 // <string> 14 15 // basic_string(basic_string<charT,traits,Allocator>&& str); // constexpr since C++20 16 17 #include <string> 18 #include <cassert> 19 20 #include "test_macros.h" 21 #include "test_allocator.h" 22 #include "min_allocator.h" 23 24 template <class S> 25 TEST_CONSTEXPR_CXX20 void 26 test(S s0) 27 { 28 S s1 = s0; 29 S s2 = std::move(s0); 30 LIBCPP_ASSERT(s2.__invariants()); 31 LIBCPP_ASSERT(s0.__invariants()); 32 assert(s2 == s1); 33 assert(s2.capacity() >= s2.size()); 34 assert(s2.get_allocator() == s1.get_allocator()); 35 } 36 37 TEST_CONSTEXPR_CXX20 bool test() { 38 { 39 typedef test_allocator<char> A; 40 typedef std::basic_string<char, std::char_traits<char>, A> S; 41 test(S(A(3))); 42 test(S("1", A(5))); 43 test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A(7))); 44 } 45 { 46 typedef min_allocator<char> A; 47 typedef std::basic_string<char, std::char_traits<char>, A> S; 48 test(S(A{})); 49 test(S("1", A())); 50 test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A())); 51 } 52 53 return true; 54 } 55 56 int main(int, char**) 57 { 58 test(); 59 #if TEST_STD_VER > 17 60 static_assert(test()); 61 #endif 62 63 return 0; 64 } 65