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 // clang-format off 23 template <template <class> class Alloc> 24 TEST_CONSTEXPR_CXX20 void test_string() { 25 { 26 std::basic_string<char, std::char_traits<char>, Alloc<char> > s = {'a', 'b', 'c'}; 27 assert(s == "abc"); 28 } 29 #ifndef TEST_HAS_NO_WIDE_CHARACTERS 30 { 31 std::basic_string<wchar_t, std::char_traits<wchar_t>, Alloc<wchar_t> > s = {L'a', L'b', L'c'}; 32 assert(s == L"abc"); 33 } 34 #endif 35 } 36 // clang-format on 37 38 TEST_CONSTEXPR_CXX20 bool test() { 39 test_string<std::allocator>(); 40 test_string<min_allocator>(); 41 42 return true; 43 } 44 45 int main(int, char**) { 46 test(); 47 #if TEST_STD_VER > 17 48 static_assert(test()); 49 #endif 50 51 return 0; 52 } 53