[mlir][acc] Introduce MappableType interface (#122146)
[llvm-project.git] / libcxx / test / std / strings / basic.string / string.cons / default.pass.cpp
blobfc263f9820cb5b79f14d2c201a3d7d38fc5400d7
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"
18 #include "asan_testing.h"
20 #if TEST_STD_VER >= 11
21 // Test the noexcept specification, which is a conforming extension
22 LIBCPP_STATIC_ASSERT(std::is_nothrow_default_constructible<std::string>::value, "");
23 LIBCPP_STATIC_ASSERT(std::is_nothrow_default_constructible<
24 std::basic_string<char, std::char_traits<char>, test_allocator<char>>>::value,
25 "");
26 LIBCPP_STATIC_ASSERT(!std::is_nothrow_default_constructible<
27 std::basic_string<char, std::char_traits<char>, limited_allocator<char, 10>>>::value,
28 "");
29 #endif
31 TEST_CONSTEXPR_CXX20 bool test() {
32 std::string str;
33 assert(str.empty());
34 LIBCPP_ASSERT(is_string_asan_correct(str));
36 return true;
39 int main(int, char**) {
40 test();
41 #if TEST_STD_VER > 17
42 static_assert(test());
43 #endif
45 return 0;