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 // template <> class codecvt<char16_t, char, mbstate_t>
12 
13 // result unshift(stateT& state,
14 //                externT* to, externT* to_end, externT*& to_next) const;
15 
16 // This test runs in C++20, but we have deprecated codecvt<char(16|32), char, mbstate_t> in C++20.
17 // ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS
18 
19 #include <locale>
20 #include <string>
21 #include <vector>
22 #include <cassert>
23 
24 #include "test_macros.h"
25 
26 typedef std::codecvt<char16_t, char, std::mbstate_t> F;
27 
main(int,char **)28 int main(int, char**)
29 {
30     std::locale l = std::locale::classic();
31     std::vector<char> to(3);
32     const F& f = std::use_facet<F>(l);
33     std::mbstate_t mbs = {};
34     char* to_next = 0;
35     assert(f.unshift(mbs, to.data(), to.data() + to.size(), to_next) == F::noconv);
36     assert(to_next == to.data());
37 
38   return 0;
39 }
40