Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / libcxx / test / std / strings / basic.string / string.cons / default.pass.cpp
blob3993a40dd5a165c24c7cd654571bb34273088991
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 // <string>
11 // basic_string() noexcept(is_nothrow_default_constructible<allocator_type>::value); // constexpr since C++20
13 #include <cassert>
14 #include <string>
16 #include "test_macros.h"
17 #include "test_allocator.h"
19 #if TEST_STD_VER >= 11
20 // Test the noexcept specification, which is a conforming extension
21 LIBCPP_STATIC_ASSERT(std::is_nothrow_default_constructible<std::string>::value, "");
22 LIBCPP_STATIC_ASSERT(std::is_nothrow_default_constructible<
23 std::basic_string<char, std::char_traits<char>, test_allocator<char>>>::value,
24 "");
25 LIBCPP_STATIC_ASSERT(!std::is_nothrow_default_constructible<
26 std::basic_string<char, std::char_traits<char>, limited_allocator<char, 10>>>::value,
27 "");
28 #endif
30 TEST_CONSTEXPR_CXX20 bool test() {
31 std::string str;
32 assert(str.empty());
34 return true;
37 int main(int, char**) {
38 test();
39 #if TEST_STD_VER > 17
40 static_assert(test());
41 #endif
43 return 0;