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 // template<class charT, class traits, class Allocator> 14 // basic_string<charT,traits,Allocator> 15 // operator+(charT lhs, const basic_string<charT,traits,Allocator>& rhs); // constexpr since C++20 16 17 // template<class charT, class traits, class Allocator> 18 // basic_string<charT,traits,Allocator>&& 19 // operator+(charT lhs, basic_string<charT,traits,Allocator>&& rhs); // constexpr since C++20 20 21 #include <string> 22 #include <utility> 23 #include <cassert> 24 25 #include "test_macros.h" 26 #include "min_allocator.h" 27 28 template <class S> 29 TEST_CONSTEXPR_CXX20 void test0(typename S::value_type lhs, const S& rhs, const S& x) { 30 assert(lhs + rhs == x); 31 } 32 33 #if TEST_STD_VER >= 11 34 template <class S> 35 TEST_CONSTEXPR_CXX20 void test1(typename S::value_type lhs, S&& rhs, const S& x) { 36 assert(lhs + std::move(rhs) == x); 37 } 38 #endif 39 40 TEST_CONSTEXPR_CXX20 bool test() { 41 { 42 typedef std::string S; 43 test0('a', S(""), S("a")); 44 test0('a', S("12345"), S("a12345")); 45 test0('a', S("1234567890"), S("a1234567890")); 46 test0('a', S("12345678901234567890"), S("a12345678901234567890")); 47 } 48 #if TEST_STD_VER >= 11 49 { 50 typedef std::string S; 51 test1('a', S(""), S("a")); 52 test1('a', S("12345"), S("a12345")); 53 test1('a', S("1234567890"), S("a1234567890")); 54 test1('a', S("12345678901234567890"), S("a12345678901234567890")); 55 } 56 { 57 typedef std::basic_string<char, std::char_traits<char>, 58 min_allocator<char> > 59 S; 60 test0('a', S(""), S("a")); 61 test0('a', S("12345"), S("a12345")); 62 test0('a', S("1234567890"), S("a1234567890")); 63 test0('a', S("12345678901234567890"), S("a12345678901234567890")); 64 65 test1('a', S(""), S("a")); 66 test1('a', S("12345"), S("a12345")); 67 test1('a', S("1234567890"), S("a1234567890")); 68 test1('a', S("12345678901234567890"), S("a12345678901234567890")); 69 } 70 #endif 71 72 return true; 73 } 74 75 int main(int, char**) { 76 test(); 77 #if TEST_STD_VER > 17 78 static_assert(test()); 79 #endif 80 81 return 0; 82 } 83