Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / libcxx / test / std / experimental / memory / memory.resource.aliases / header_string_synop.pass.cpp
blob818c6691be91c269a80c1e735a2599b95633ab50
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 // XFAIL: availability-aligned_allocation-missing
13 // <experimental/string>
15 // namespace std { namespace experimental { namespace pmr {
16 // template <class Char, class Traits = ...>
17 // using basic_string =
18 // ::std::basic_string<Char, Traits, polymorphic_allocator<Char>>
20 // typedef ... string
21 // typedef ... u16string
22 // typedef ... u32string
23 // typedef ... wstring
25 // }}} // namespace std::experimental::pmr
27 // ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS
29 #include <experimental/string>
30 #include <experimental/memory_resource>
31 #include <type_traits>
32 #include <cassert>
34 #include "constexpr_char_traits.h"
36 #include "test_macros.h"
38 namespace pmr = std::experimental::pmr;
40 template <class Char, class PmrTypedef>
41 void test_string_typedef() {
42 using StdStr = std::basic_string<Char, std::char_traits<Char>,
43 pmr::polymorphic_allocator<Char>>;
44 using PmrStr = pmr::basic_string<Char>;
45 static_assert(std::is_same<StdStr, PmrStr>::value, "");
46 static_assert(std::is_same<PmrStr, PmrTypedef>::value, "");
49 template <class Char, class Traits>
50 void test_basic_string_alias() {
51 using StdStr = std::basic_string<Char, Traits,
52 pmr::polymorphic_allocator<Char>>;
53 using PmrStr = pmr::basic_string<Char, Traits>;
54 static_assert(std::is_same<StdStr, PmrStr>::value, "");
57 int main(int, char**)
60 test_string_typedef<char, pmr::string>();
61 #ifndef TEST_HAS_NO_WIDE_CHARACTERS
62 test_string_typedef<wchar_t, pmr::wstring>();
63 #endif
64 test_string_typedef<char16_t, pmr::u16string>();
65 test_string_typedef<char32_t, pmr::u32string>();
68 test_basic_string_alias<char, constexpr_char_traits<char>>();
69 #ifndef TEST_HAS_NO_WIDE_CHARACTERS
70 test_basic_string_alias<wchar_t, constexpr_char_traits<wchar_t>>();
71 #endif
72 test_basic_string_alias<char16_t, constexpr_char_traits<char16_t>>();
73 test_basic_string_alias<char32_t, constexpr_char_traits<char32_t>>();
76 // Check that std::basic_string has been included and is complete.
77 pmr::string s;
78 assert(s.get_allocator().resource() == pmr::get_default_resource());
81 return 0;