Differential D91292 Diff 308912 libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.string/ctor_codecvt.pass.cpp
Changeset View
Changeset View
Standalone View
Standalone View
libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.string/ctor_codecvt.pass.cpp
//===----------------------------------------------------------------------===// | //===----------------------------------------------------------------------===// | ||||
// | // | ||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||||
// See https://llvm.org/LICENSE.txt for license information. | // See https://llvm.org/LICENSE.txt for license information. | ||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||||
// | // | ||||
//===----------------------------------------------------------------------===// | //===----------------------------------------------------------------------===// | ||||
// <locale> | // <locale> | ||||
// wstring_convert<Codecvt, Elem, Wide_alloc, Byte_alloc> | // wstring_convert<Codecvt, Elem, Wide_alloc, Byte_alloc> | ||||
// wstring_convert(Codecvt* pcvt = new Codecvt); | // wstring_convert(Codecvt* pcvt = new Codecvt); // before C++14 | ||||
// explicit wstring_convert(Codecvt* pcvt = new Codecvt); // before C++20 | |||||
// wstring_convert() : wstring_convert(new Codecvt) {} // C++20 | |||||
// explicit wstring_convert(Codecvt* pcvt); // C++20 | |||||
#include <locale> | #include <locale> | ||||
#include <codecvt> | #include <codecvt> | ||||
#include <cassert> | #include <cassert> | ||||
#include "test_macros.h" | #include "test_macros.h" | ||||
#if TEST_STD_VER >= 11 | |||||
#include "test_convertible.h" | |||||
#endif | |||||
int main(int, char**) | int main(int, char**) | ||||
{ | { | ||||
{ | { | ||||
typedef std::codecvt_utf8<wchar_t> Codecvt; | typedef std::codecvt_utf8<wchar_t> Codecvt; | ||||
typedef std::wstring_convert<Codecvt> Myconv; | typedef std::wstring_convert<Codecvt> Myconv; | ||||
Myconv myconv; | Myconv myconv; | ||||
assert(myconv.converted() == 0); | assert(myconv.converted() == 0); | ||||
} | } | ||||
{ | { | ||||
typedef std::codecvt_utf8<wchar_t> Codecvt; | typedef std::codecvt_utf8<wchar_t> Codecvt; | ||||
typedef std::wstring_convert<Codecvt> Myconv; | typedef std::wstring_convert<Codecvt> Myconv; | ||||
Myconv myconv(new Codecvt); | Myconv myconv(new Codecvt); | ||||
assert(myconv.converted() == 0); | assert(myconv.converted() == 0); | ||||
#if TEST_STD_VER > 11 | #if TEST_STD_VER > 11 | ||||
static_assert(!std::is_convertible<Codecvt*, Myconv>::value, ""); | static_assert(!std::is_convertible<Codecvt*, Myconv>::value, ""); | ||||
static_assert( std::is_constructible<Myconv, Codecvt*>::value, ""); | static_assert( std::is_constructible<Myconv, Codecvt*>::value, ""); | ||||
#endif | #endif | ||||
} | } | ||||
#if TEST_STD_VER >= 11 | |||||
{ | |||||
typedef std::codecvt_utf8<wchar_t> Codecvt; | |||||
typedef std::wstring_convert<Codecvt> B; | |||||
#if TEST_STD_VER > 17 | |||||
static_assert(test_convertible<B>(), ""); | |||||
static_assert(!test_convertible<B, Codecvt*>(), ""); | |||||
#elif TEST_STD_VER > 11 | |||||
static_assert(!test_convertible<B>(), ""); | |||||
static_assert(!test_convertible<B, Codecvt*>(), ""); | |||||
#else | |||||
static_assert(test_convertible<B>(), ""); | |||||
static_assert(test_convertible<B, Codecvt*>(), ""); | |||||
#endif | |||||
} | |||||
#endif | |||||
return 0; | return 0; | ||||
} | } |