| 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 <codecvt> |
| 24 |
#include <cassert> |
| 25 |
|
| 26 |
#include "test_macros.h" |
| 27 |
#if TEST_STD_VER >= 11 |
| 28 |
#include "test_convertible.h" |
| 29 |
#endif |
| 30 |
|
| 31 |
int main(int, char**) |
| 32 |
{ |
| 33 |
{ |
| 34 |
typedef std::codecvt_utf8<wchar_t> Codecvt; |
| 35 |
typedef std::wstring_convert<Codecvt> Myconv; |
| 36 |
Myconv myconv; |
| 37 |
assert(myconv.converted() == 0); |
| 38 |
} |
| 39 |
{ |
| 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 |
| 48 |
} |
| 49 |
|
| 50 |
#if TEST_STD_VER >= 11 |
| 51 |
{ |
| 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*>(), ""); |
| 56 |
} |
| 57 |
#endif |
| 58 |
|
| 59 |
return 0; |
| 60 |
} |