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, char8_t, mbstate_t>
12 
13 // result in(stateT& state,
14 //           const externT* from, const externT* from_end, const externT*& from_next,
15 //           internT* to, internT* to_end, internT*& to_next) const;
16 
17 // UNSUPPORTED: c++03, c++11, c++14, c++17
18 
19 // C++20 codecvt specializations for char8_t are not yet implemented:
20 // UNSUPPORTED: libc++
21 
22 #include <cassert>
23 #include <locale>
24 
main(int,char **)25 int main(int, char**) {
26   using F = std::codecvt<char16_t, char8_t, std::mbstate_t>;
27   const F::extern_type from[] = u8"some text";
28   F::intern_type to[9];
29   const F& f = std::use_facet<F>(std::locale::classic());
30   std::mbstate_t mbs = {};
31   const F::extern_type* from_next = nullptr;
32   F::intern_type* to_next = nullptr;
33   assert(f.in(mbs, from, from + 9, from_next, to, to + 9, to_next) == F::ok);
34   assert(from_next - from == 9);
35   assert(to_next - to == 9);
36   for (unsigned i = 0; i < 9; ++i)
37     assert(to[i] == from[i]);
38   return 0;
39 }
40