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 // <string> 12 13 // basic_string(initializer_list<charT> il, const Allocator& a = Allocator()); // constexpr since C++20 14 15 #include <string> 16 #include <cassert> 17 18 #include "test_macros.h" 19 #include "test_allocator.h" 20 #include "min_allocator.h" 21 22 TEST_CONSTEXPR_CXX20 bool test() { 23 { 24 std::string s = {'a', 'b', 'c'}; 25 assert(s == "abc"); 26 } 27 #ifndef TEST_HAS_NO_WIDE_CHARACTERS 28 { 29 std::wstring s; 30 s = {L'a', L'b', L'c'}; 31 assert(s == L"abc"); 32 } 33 #endif 34 { 35 typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; 36 S s = {'a', 'b', 'c'}; 37 assert(s == "abc"); 38 } 39 #ifndef TEST_HAS_NO_WIDE_CHARACTERS 40 { 41 typedef std::basic_string<wchar_t, std::char_traits<wchar_t>, min_allocator<wchar_t>> S; 42 S s; 43 s = {L'a', L'b', L'c'}; 44 assert(s == L"abc"); 45 } 46 #endif 47 48 return true; 49 } 50 51 int main(int, char**) { 52 test(); 53 #if TEST_STD_VER > 17 54 static_assert(test()); 55 #endif 56 57 return 0; 58 } 59