Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / libcxx / test / std / localization / locales / locale.convenience / conversions / conversions.string / ctor_codecvt.pass.cpp
blob8c0321049663dfa35fcac281d31802ceccdddd75
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 // <locale>
11 // ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS
13 // wstring_convert<Codecvt, Elem, Wide_alloc, Byte_alloc>
15 // wstring_convert(Codecvt* pcvt = new Codecvt); // before C++14
16 // explicit wstring_convert(Codecvt* pcvt = new Codecvt); // before C++20
17 // wstring_convert() : wstring_convert(new Codecvt) {} // C++20
18 // explicit wstring_convert(Codecvt* pcvt); // C++20
20 // XFAIL: no-wide-characters
22 #include <locale>
23 #include <codecvt>
24 #include <cassert>
26 #include "test_macros.h"
27 #if TEST_STD_VER >= 11
28 #include "test_convertible.h"
29 #endif
31 int main(int, char**)
34 typedef std::codecvt_utf8<wchar_t> Codecvt;
35 typedef std::wstring_convert<Codecvt> Myconv;
36 Myconv myconv;
37 assert(myconv.converted() == 0);
40 typedef std::codecvt_utf8<wchar_t> Codecvt;
41 typedef std::wstring_convert<Codecvt> Myconv;
42 Myconv myconv(new Codecvt);
43 assert(myconv.converted() == 0);
44 #if TEST_STD_VER > 11
45 static_assert(!std::is_convertible<Codecvt*, Myconv>::value, "");
46 static_assert( std::is_constructible<Myconv, Codecvt*>::value, "");
47 #endif
50 #if TEST_STD_VER >= 11
52 typedef std::codecvt_utf8<wchar_t> Codecvt;
53 typedef std::wstring_convert<Codecvt> B;
54 static_assert(test_convertible<B>(), "");
55 static_assert(!test_convertible<B, Codecvt*>(), "");
57 #endif
59 return 0;