Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / libcxx / test / std / strings / basic.string / string.cons / initializer_list.pass.cpp
blob5b7e8bde2e6e877ee13b155e7beeda6bd23286e5
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 //===----------------------------------------------------------------------===//
9 // UNSUPPORTED: c++03
11 // <string>
13 // basic_string(initializer_list<charT> il, const Allocator& a = Allocator()); // constexpr since C++20
15 #include <string>
16 #include <cassert>
18 #include "test_macros.h"
19 #include "test_allocator.h"
20 #include "min_allocator.h"
22 // clang-format off
23 template <template <class> class Alloc>
24 TEST_CONSTEXPR_CXX20 void test_string() {
26 std::basic_string<char, std::char_traits<char>, Alloc<char> > s = {'a', 'b', 'c'};
27 assert(s == "abc");
29 #ifndef TEST_HAS_NO_WIDE_CHARACTERS
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");
34 #endif
36 // clang-format on
38 TEST_CONSTEXPR_CXX20 bool test() {
39 test_string<std::allocator>();
40 test_string<min_allocator>();
42 return true;
45 int main(int, char**) {
46 test();
47 #if TEST_STD_VER > 17
48 static_assert(test());
49 #endif
51 return 0;