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(initializer_list<charT> il, const Allocator& a = Allocator()); // 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 TEST_CONSTEXPR_CXX20 bool test() { 25 { 26 std::string s = {'a', 'b', 'c'}; 27 assert(s == "abc"); 28 } 29 #ifndef TEST_HAS_NO_WIDE_CHARACTERS 30 { 31 std::wstring s; 32 s = {L'a', L'b', L'c'}; 33 assert(s == L"abc"); 34 } 35 #endif 36 { 37 typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; 38 S s = {'a', 'b', 'c'}; 39 assert(s == "abc"); 40 } 41 #ifndef TEST_HAS_NO_WIDE_CHARACTERS 42 { 43 typedef std::basic_string<wchar_t, std::char_traits<wchar_t>, min_allocator<wchar_t>> S; 44 S s; 45 s = {L'a', L'b', L'c'}; 46 assert(s == L"abc"); 47 } 48 #endif 49 50 return true; 51 } 52 53 int main(int, char**) 54 { 55 test(); 56 #if TEST_STD_VER > 17 57 static_assert(test()); 58 #endif 59 60 return 0; 61 } 62