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 out(stateT& state,
14 //            const internT* from, const internT* from_end, const internT*& from_next,
15 //            externT* to, externT* to_end, externT*& 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& f = std::use_facet<F>(std::locale::classic());
28   F::intern_type from[9] = {'s', 'o', 'm', 'e', ' ', 't', 'e', 'x', 't'};
29   F::extern_type to[9] = {0};
30   std::mbstate_t mbs = {};
31   const F::intern_type* from_next = nullptr;
32   F::extern_type* to_next = nullptr;
33   F::result r = f.out(mbs, from, from + 9, from_next, to, to + 9, to_next);
34   assert(r == F::ok);
35   assert(from_next - from == 9);
36   assert(to_next - to == 9);
37   for (unsigned i = 0; i < 9; ++i)
38     assert(to[i] == from[i]);
39   return 0;
40 }
41