1 //===----------------------------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
11 // ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS -D_LIBCPP_ENABLE_CXX26_REMOVED_CODECVT -D_LIBCPP_ENABLE_CXX26_REMOVED_WSTRING_CONVERT
13 // wbuffer_convert<Codecvt, Elem, Tr>
15 // wbuffer_convert(streambuf* bytebuf = 0, Codecvt* pcvt = new Codecvt,
16 // state_type state = state_type()); // before C++14
17 // explicit wbuffer_convert(streambuf* bytebuf = nullptr, Codecvt* pcvt = new Codecvt,
18 // state_type state = state_type()); // before C++20
19 // wbuffer_convert() : wbuffer_convert(nullptr) {} // C++20
20 // explicit wbuffer_convert(streambuf* bytebuf, Codecvt* pcvt = new Codecvt,
21 // state_type state = state_type()); // C++20
23 // XFAIL: no-wide-characters
30 #include "test_macros.h"
31 #include "count_new.h"
32 #if TEST_STD_VER >= 11
33 #include "test_convertible.h"
38 globalMemCounter
.reset();
39 typedef std::wbuffer_convert
<std::codecvt_utf8
<wchar_t> > B
;
41 static_assert(!std::is_convertible
<std::streambuf
*, B
>::value
, "");
42 static_assert( std::is_constructible
<B
, std::streambuf
*>::value
, "");
46 assert(b
.rdbuf() == nullptr);
47 assert(globalMemCounter
.checkOutstandingNewNotEq(0));
49 assert(globalMemCounter
.checkOutstandingNewEq(0));
53 assert(b
.rdbuf() == s
.rdbuf());
54 assert(globalMemCounter
.checkOutstandingNewNotEq(0));
56 assert(globalMemCounter
.checkOutstandingNewEq(0));
59 B
b(s
.rdbuf(), new std::codecvt_utf8
<wchar_t>);
60 assert(b
.rdbuf() == s
.rdbuf());
61 assert(globalMemCounter
.checkOutstandingNewNotEq(0));
63 assert(globalMemCounter
.checkOutstandingNewEq(0));
66 B
b(s
.rdbuf(), new std::codecvt_utf8
<wchar_t>, std::mbstate_t());
67 assert(b
.rdbuf() == s
.rdbuf());
68 assert(globalMemCounter
.checkOutstandingNewNotEq(0));
70 assert(globalMemCounter
.checkOutstandingNewEq(0));
72 #if TEST_STD_VER >= 11
74 static_assert(test_convertible
<B
>(), "");
75 static_assert(!test_convertible
<B
, std::streambuf
*>(), "");