| 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 | //===----------------------------------------------------------------------===// |
| 8 | |
| 9 | // <locale> |
| 10 | |
| 11 | // ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS -D_LIBCPP_ENABLE_CXX26_REMOVED_CODECVT -D_LIBCPP_ENABLE_CXX26_REMOVED_WSTRING_CONVERT |
| 12 | |
| 13 | // wstring_convert<Codecvt, Elem, Wide_alloc, Byte_alloc> |
| 14 | |
| 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 |
| 19 | |
| 20 | // XFAIL: no-wide-characters |
| 21 | |
| 22 | #include <locale> |
| 23 | #include <cassert> |
| 24 | #include <codecvt> |
| 25 | #include <type_traits> |
| 26 | |
| 27 | #include "test_macros.h" |
| 28 | #if TEST_STD_VER >= 11 |
| 29 | #include "test_convertible.h" |
| 30 | #endif |
| 31 | |
| 32 | int main(int, char**) |
| 33 | { |
| 34 | { |
| 35 | typedef std::codecvt_utf8<wchar_t> Codecvt; |
| 36 | typedef std::wstring_convert<Codecvt> Myconv; |
| 37 | Myconv myconv; |
| 38 | assert(myconv.converted() == 0); |
| 39 | } |
| 40 | { |
| 41 | typedef std::codecvt_utf8<wchar_t> Codecvt; |
| 42 | typedef std::wstring_convert<Codecvt> Myconv; |
| 43 | Myconv myconv(new Codecvt); |
| 44 | assert(myconv.converted() == 0); |
| 45 | #if TEST_STD_VER > 11 |
| 46 | static_assert(!std::is_convertible<Codecvt*, Myconv>::value, "" ); |
| 47 | static_assert( std::is_constructible<Myconv, Codecvt*>::value, "" ); |
| 48 | #endif |
| 49 | } |
| 50 | |
| 51 | #if TEST_STD_VER >= 11 |
| 52 | { |
| 53 | typedef std::codecvt_utf8<wchar_t> Codecvt; |
| 54 | typedef std::wstring_convert<Codecvt> B; |
| 55 | static_assert(test_convertible<B>(), "" ); |
| 56 | static_assert(!test_convertible<B, Codecvt*>(), "" ); |
| 57 | } |
| 58 | #endif |
| 59 | |
| 60 | return 0; |
| 61 | } |
| 62 | |