xref: /freebsd/contrib/llvm-project/libcxx/include/codecvt (revision 5f757f3ff9144b609b3c433dfd370cc6bdc191ad)
1// -*- C++ -*-
2//===----------------------------------------------------------------------===//
3//
4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5// See https://llvm.org/LICENSE.txt for license information.
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef _LIBCPP_CODECVT
11#define _LIBCPP_CODECVT
12
13/*
14    codecvt synopsis
15
16namespace std
17{
18
19enum codecvt_mode
20{
21    consume_header = 4,
22    generate_header = 2,
23    little_endian = 1
24};
25
26template <class Elem, unsigned long Maxcode = 0x10ffff,
27          codecvt_mode Mode = (codecvt_mode)0>
28class codecvt_utf8
29    : public codecvt<Elem, char, mbstate_t>
30{
31    explicit codecvt_utf8(size_t refs = 0);
32    ~codecvt_utf8();
33};
34
35template <class Elem, unsigned long Maxcode = 0x10ffff,
36          codecvt_mode Mode = (codecvt_mode)0>
37class codecvt_utf16
38    : public codecvt<Elem, char, mbstate_t>
39{
40    explicit codecvt_utf16(size_t refs = 0);
41    ~codecvt_utf16();
42};
43
44template <class Elem, unsigned long Maxcode = 0x10ffff,
45          codecvt_mode Mode = (codecvt_mode)0>
46class codecvt_utf8_utf16
47    : public codecvt<Elem, char, mbstate_t>
48{
49    explicit codecvt_utf8_utf16(size_t refs = 0);
50    ~codecvt_utf8_utf16();
51};
52
53}  // std
54
55*/
56
57#include <__assert> // all public C++ headers provide the assertion handler
58#include <__config>
59#include <__locale>
60#include <version>
61
62#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
63#  pragma GCC system_header
64#endif
65
66#if _LIBCPP_STD_VER < 26 || defined(_LIBCPP_BUILDING_LIBRARY) || defined(_LIBCPP_ENABLE_CXX26_REMOVED_CODECVT)
67
68_LIBCPP_BEGIN_NAMESPACE_STD
69
70enum _LIBCPP_DEPRECATED_IN_CXX17 codecvt_mode
71{
72    consume_header = 4,
73    generate_header = 2,
74    little_endian = 1
75};
76
77// codecvt_utf8
78
79template <class _Elem> class __codecvt_utf8;
80
81#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
82template <>
83class _LIBCPP_EXPORTED_FROM_ABI __codecvt_utf8<wchar_t>
84    : public codecvt<wchar_t, char, mbstate_t>
85{
86    unsigned long __maxcode_;
87_LIBCPP_SUPPRESS_DEPRECATED_PUSH
88    codecvt_mode __mode_;
89_LIBCPP_SUPPRESS_DEPRECATED_POP
90public:
91    typedef wchar_t   intern_type;
92    typedef char      extern_type;
93    typedef mbstate_t state_type;
94
95_LIBCPP_SUPPRESS_DEPRECATED_PUSH
96    _LIBCPP_HIDE_FROM_ABI
97    explicit __codecvt_utf8(size_t __refs, unsigned long __maxcode,
98                            codecvt_mode __mode)
99        : codecvt<wchar_t, char, mbstate_t>(__refs), __maxcode_(__maxcode),
100          __mode_(__mode) {}
101_LIBCPP_SUPPRESS_DEPRECATED_POP
102protected:
103    result do_out(state_type& __st,
104                  const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
105                  extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override;
106    result do_in(state_type& __st,
107                 const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
108                 intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const override;
109    result do_unshift(state_type& __st,
110                      extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override;
111    int do_encoding() const _NOEXCEPT override;
112    bool do_always_noconv() const _NOEXCEPT override;
113    int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const override;
114    int do_max_length() const _NOEXCEPT override;
115};
116#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
117
118_LIBCPP_SUPPRESS_DEPRECATED_PUSH
119template <>
120class _LIBCPP_EXPORTED_FROM_ABI __codecvt_utf8<char16_t>
121    : public codecvt<char16_t, char, mbstate_t>
122{
123    unsigned long __maxcode_;
124    codecvt_mode __mode_;
125public:
126    typedef char16_t  intern_type;
127    typedef char      extern_type;
128    typedef mbstate_t state_type;
129
130    _LIBCPP_HIDE_FROM_ABI
131    explicit __codecvt_utf8(size_t __refs, unsigned long __maxcode,
132                            codecvt_mode __mode)
133        : codecvt<char16_t, char, mbstate_t>(__refs), __maxcode_(__maxcode),
134          __mode_(__mode) {}
135_LIBCPP_SUPPRESS_DEPRECATED_POP
136
137protected:
138     result do_out(state_type& __st,
139                   const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
140                   extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override;
141     result do_in(state_type& __st,
142                  const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
143                  intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const override;
144     result do_unshift(state_type& __st,
145                       extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override;
146     int do_encoding() const _NOEXCEPT override;
147     bool do_always_noconv() const _NOEXCEPT override;
148     int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const override;
149     int do_max_length() const _NOEXCEPT override;
150};
151
152_LIBCPP_SUPPRESS_DEPRECATED_PUSH
153template <>
154class _LIBCPP_EXPORTED_FROM_ABI __codecvt_utf8<char32_t>
155    : public codecvt<char32_t, char, mbstate_t>
156{
157    unsigned long __maxcode_;
158    codecvt_mode __mode_;
159public:
160    typedef char32_t  intern_type;
161    typedef char      extern_type;
162    typedef mbstate_t state_type;
163
164    _LIBCPP_HIDE_FROM_ABI
165    explicit __codecvt_utf8(size_t __refs, unsigned long __maxcode,
166                            codecvt_mode __mode)
167        : codecvt<char32_t, char, mbstate_t>(__refs), __maxcode_(__maxcode),
168          __mode_(__mode) {}
169_LIBCPP_SUPPRESS_DEPRECATED_POP
170
171protected:
172     result do_out(state_type& __st,
173                   const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
174                   extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override;
175     result do_in(state_type& __st,
176                  const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
177                  intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const override;
178     result do_unshift(state_type& __st,
179                       extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override;
180     int do_encoding() const _NOEXCEPT override;
181     bool do_always_noconv() const _NOEXCEPT override;
182     int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const override;
183     int do_max_length() const _NOEXCEPT override;
184};
185
186_LIBCPP_SUPPRESS_DEPRECATED_PUSH
187template <class _Elem, unsigned long _Maxcode = 0x10ffff,
188          codecvt_mode _Mode = (codecvt_mode)0>
189class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 codecvt_utf8
190    : public __codecvt_utf8<_Elem>
191{
192public:
193    _LIBCPP_HIDE_FROM_ABI
194    explicit codecvt_utf8(size_t __refs = 0)
195        : __codecvt_utf8<_Elem>(__refs, _Maxcode, _Mode) {}
196
197    _LIBCPP_HIDE_FROM_ABI
198    ~codecvt_utf8() {}
199};
200_LIBCPP_SUPPRESS_DEPRECATED_POP
201
202// codecvt_utf16
203
204template <class _Elem, bool _LittleEndian> class __codecvt_utf16;
205
206#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
207template <>
208class _LIBCPP_EXPORTED_FROM_ABI __codecvt_utf16<wchar_t, false>
209    : public codecvt<wchar_t, char, mbstate_t>
210{
211    unsigned long __maxcode_;
212_LIBCPP_SUPPRESS_DEPRECATED_PUSH
213    codecvt_mode __mode_;
214_LIBCPP_SUPPRESS_DEPRECATED_POP
215public:
216    typedef wchar_t   intern_type;
217    typedef char      extern_type;
218    typedef mbstate_t state_type;
219
220_LIBCPP_SUPPRESS_DEPRECATED_PUSH
221    _LIBCPP_HIDE_FROM_ABI
222    explicit __codecvt_utf16(size_t __refs, unsigned long __maxcode,
223                            codecvt_mode __mode)
224        : codecvt<wchar_t, char, mbstate_t>(__refs), __maxcode_(__maxcode),
225          __mode_(__mode) {}
226_LIBCPP_SUPPRESS_DEPRECATED_POP
227protected:
228     result do_out(state_type& __st,
229                   const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
230                   extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override;
231     result do_in(state_type& __st,
232                  const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
233                  intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const override;
234     result do_unshift(state_type& __st,
235                       extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override;
236     int do_encoding() const _NOEXCEPT override;
237     bool do_always_noconv() const _NOEXCEPT override;
238     int do_length(state_type&, const extern_type* __frm, const extern_type* __end,
239                          size_t __mx) const override;
240     int do_max_length() const _NOEXCEPT override;
241};
242
243template <>
244class _LIBCPP_EXPORTED_FROM_ABI __codecvt_utf16<wchar_t, true>
245    : public codecvt<wchar_t, char, mbstate_t>
246{
247    unsigned long __maxcode_;
248_LIBCPP_SUPPRESS_DEPRECATED_PUSH
249    codecvt_mode __mode_;
250_LIBCPP_SUPPRESS_DEPRECATED_POP
251public:
252    typedef wchar_t   intern_type;
253    typedef char      extern_type;
254    typedef mbstate_t state_type;
255
256_LIBCPP_SUPPRESS_DEPRECATED_PUSH
257    _LIBCPP_HIDE_FROM_ABI
258    explicit __codecvt_utf16(size_t __refs, unsigned long __maxcode,
259                            codecvt_mode __mode)
260        : codecvt<wchar_t, char, mbstate_t>(__refs), __maxcode_(__maxcode),
261          __mode_(__mode) {}
262_LIBCPP_SUPPRESS_DEPRECATED_POP
263protected:
264     result do_out(state_type& __st,
265                   const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
266                   extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override;
267     result do_in(state_type& __st,
268                  const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
269                  intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const override;
270     result do_unshift(state_type& __st,
271                       extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override;
272     int do_encoding() const _NOEXCEPT override;
273     bool do_always_noconv() const _NOEXCEPT override;
274     int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const override;
275     int do_max_length() const _NOEXCEPT override;
276};
277#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
278
279_LIBCPP_SUPPRESS_DEPRECATED_PUSH
280template <>
281class _LIBCPP_EXPORTED_FROM_ABI __codecvt_utf16<char16_t, false>
282    : public codecvt<char16_t, char, mbstate_t>
283{
284    unsigned long __maxcode_;
285    codecvt_mode __mode_;
286public:
287    typedef char16_t  intern_type;
288    typedef char      extern_type;
289    typedef mbstate_t state_type;
290
291    _LIBCPP_HIDE_FROM_ABI
292    explicit __codecvt_utf16(size_t __refs, unsigned long __maxcode,
293                            codecvt_mode __mode)
294        : codecvt<char16_t, char, mbstate_t>(__refs), __maxcode_(__maxcode),
295          __mode_(__mode) {}
296_LIBCPP_SUPPRESS_DEPRECATED_POP
297
298protected:
299     result do_out(state_type& __st,
300                   const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
301                   extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override;
302     result do_in(state_type& __st,
303                  const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
304                  intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const override;
305     result do_unshift(state_type& __st,
306                       extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override;
307     int do_encoding() const _NOEXCEPT override;
308     bool do_always_noconv() const _NOEXCEPT override;
309     int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const override;
310     int do_max_length() const _NOEXCEPT override;
311};
312
313_LIBCPP_SUPPRESS_DEPRECATED_PUSH
314template <>
315class _LIBCPP_EXPORTED_FROM_ABI __codecvt_utf16<char16_t, true>
316    : public codecvt<char16_t, char, mbstate_t>
317{
318    unsigned long __maxcode_;
319    codecvt_mode __mode_;
320public:
321    typedef char16_t  intern_type;
322    typedef char      extern_type;
323    typedef mbstate_t state_type;
324
325    _LIBCPP_HIDE_FROM_ABI
326    explicit __codecvt_utf16(size_t __refs, unsigned long __maxcode,
327                            codecvt_mode __mode)
328        : codecvt<char16_t, char, mbstate_t>(__refs), __maxcode_(__maxcode),
329          __mode_(__mode) {}
330_LIBCPP_SUPPRESS_DEPRECATED_POP
331
332protected:
333     result do_out(state_type& __st,
334                   const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
335                   extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override;
336     result do_in(state_type& __st,
337                  const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
338                  intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const override;
339     result do_unshift(state_type& __st,
340                       extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override;
341     int do_encoding() const _NOEXCEPT override;
342     bool do_always_noconv() const _NOEXCEPT override;
343     int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const override;
344     int do_max_length() const _NOEXCEPT override;
345};
346
347_LIBCPP_SUPPRESS_DEPRECATED_PUSH
348template <>
349class _LIBCPP_EXPORTED_FROM_ABI __codecvt_utf16<char32_t, false>
350    : public codecvt<char32_t, char, mbstate_t>
351{
352    unsigned long __maxcode_;
353    codecvt_mode __mode_;
354public:
355    typedef char32_t  intern_type;
356    typedef char      extern_type;
357    typedef mbstate_t state_type;
358
359    _LIBCPP_HIDE_FROM_ABI
360    explicit __codecvt_utf16(size_t __refs, unsigned long __maxcode,
361                            codecvt_mode __mode)
362        : codecvt<char32_t, char, mbstate_t>(__refs), __maxcode_(__maxcode),
363          __mode_(__mode) {}
364_LIBCPP_SUPPRESS_DEPRECATED_POP
365
366protected:
367     result do_out(state_type& __st,
368                   const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
369                   extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override;
370     result do_in(state_type& __st,
371                  const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
372                  intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const override;
373     result do_unshift(state_type& __st,
374                       extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override;
375     int do_encoding() const _NOEXCEPT override;
376     bool do_always_noconv() const _NOEXCEPT override;
377     int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const override;
378     int do_max_length() const _NOEXCEPT override;
379};
380
381_LIBCPP_SUPPRESS_DEPRECATED_PUSH
382template <>
383class _LIBCPP_EXPORTED_FROM_ABI __codecvt_utf16<char32_t, true>
384    : public codecvt<char32_t, char, mbstate_t>
385{
386    unsigned long __maxcode_;
387    codecvt_mode __mode_;
388public:
389    typedef char32_t  intern_type;
390    typedef char      extern_type;
391    typedef mbstate_t state_type;
392
393    _LIBCPP_HIDE_FROM_ABI
394    explicit __codecvt_utf16(size_t __refs, unsigned long __maxcode,
395                            codecvt_mode __mode)
396        : codecvt<char32_t, char, mbstate_t>(__refs), __maxcode_(__maxcode),
397          __mode_(__mode) {}
398_LIBCPP_SUPPRESS_DEPRECATED_POP
399
400protected:
401     result do_out(state_type& __st,
402                   const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
403                   extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override;
404     result do_in(state_type& __st,
405                  const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
406                  intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const override;
407     result do_unshift(state_type& __st,
408                       extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override;
409     int do_encoding() const _NOEXCEPT override;
410     bool do_always_noconv() const _NOEXCEPT override;
411     int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const override;
412     int do_max_length() const _NOEXCEPT override;
413};
414
415_LIBCPP_SUPPRESS_DEPRECATED_PUSH
416template <class _Elem, unsigned long _Maxcode = 0x10ffff,
417          codecvt_mode _Mode = (codecvt_mode)0>
418class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 codecvt_utf16
419    : public __codecvt_utf16<_Elem, _Mode & little_endian>
420{
421public:
422    _LIBCPP_HIDE_FROM_ABI
423    explicit codecvt_utf16(size_t __refs = 0)
424        : __codecvt_utf16<_Elem, _Mode & little_endian>(__refs, _Maxcode, _Mode) {}
425
426    _LIBCPP_HIDE_FROM_ABI
427    ~codecvt_utf16() {}
428};
429_LIBCPP_SUPPRESS_DEPRECATED_POP
430
431// codecvt_utf8_utf16
432
433template <class _Elem> class __codecvt_utf8_utf16;
434
435#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
436template <>
437class _LIBCPP_EXPORTED_FROM_ABI __codecvt_utf8_utf16<wchar_t>
438    : public codecvt<wchar_t, char, mbstate_t>
439{
440    unsigned long __maxcode_;
441_LIBCPP_SUPPRESS_DEPRECATED_PUSH
442    codecvt_mode __mode_;
443_LIBCPP_SUPPRESS_DEPRECATED_POP
444public:
445    typedef wchar_t   intern_type;
446    typedef char      extern_type;
447    typedef mbstate_t state_type;
448
449_LIBCPP_SUPPRESS_DEPRECATED_PUSH
450    _LIBCPP_HIDE_FROM_ABI
451    explicit __codecvt_utf8_utf16(size_t __refs, unsigned long __maxcode,
452                            codecvt_mode __mode)
453        : codecvt<wchar_t, char, mbstate_t>(__refs), __maxcode_(__maxcode),
454          __mode_(__mode) {}
455_LIBCPP_SUPPRESS_DEPRECATED_POP
456protected:
457     result do_out(state_type& __st,
458                   const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
459                   extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override;
460     result do_in(state_type& __st,
461                  const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
462                  intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const override;
463     result do_unshift(state_type& __st,
464                       extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override;
465     int do_encoding() const _NOEXCEPT override;
466     bool do_always_noconv() const _NOEXCEPT override;
467     int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const override;
468     int do_max_length() const _NOEXCEPT override;
469};
470#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
471
472_LIBCPP_SUPPRESS_DEPRECATED_PUSH
473template <>
474class _LIBCPP_EXPORTED_FROM_ABI __codecvt_utf8_utf16<char32_t>
475    : public codecvt<char32_t, char, mbstate_t>
476{
477    unsigned long __maxcode_;
478    codecvt_mode __mode_;
479public:
480    typedef char32_t  intern_type;
481    typedef char      extern_type;
482    typedef mbstate_t state_type;
483
484    _LIBCPP_HIDE_FROM_ABI
485    explicit __codecvt_utf8_utf16(size_t __refs, unsigned long __maxcode,
486                            codecvt_mode __mode)
487        : codecvt<char32_t, char, mbstate_t>(__refs), __maxcode_(__maxcode),
488          __mode_(__mode) {}
489_LIBCPP_SUPPRESS_DEPRECATED_POP
490
491protected:
492     result do_out(state_type& __st,
493                   const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
494                   extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override;
495     result do_in(state_type& __st,
496                  const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
497                  intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const override;
498     result do_unshift(state_type& __st,
499                       extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override;
500     int do_encoding() const _NOEXCEPT override;
501     bool do_always_noconv() const _NOEXCEPT override;
502     int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const override;
503     int do_max_length() const _NOEXCEPT override;
504};
505
506_LIBCPP_SUPPRESS_DEPRECATED_PUSH
507template <>
508class _LIBCPP_EXPORTED_FROM_ABI __codecvt_utf8_utf16<char16_t>
509    : public codecvt<char16_t, char, mbstate_t>
510{
511    unsigned long __maxcode_;
512    codecvt_mode __mode_;
513public:
514    typedef char16_t  intern_type;
515    typedef char      extern_type;
516    typedef mbstate_t state_type;
517
518    _LIBCPP_HIDE_FROM_ABI
519    explicit __codecvt_utf8_utf16(size_t __refs, unsigned long __maxcode,
520                            codecvt_mode __mode)
521        : codecvt<char16_t, char, mbstate_t>(__refs), __maxcode_(__maxcode),
522          __mode_(__mode) {}
523_LIBCPP_SUPPRESS_DEPRECATED_POP
524
525protected:
526     result do_out(state_type& __st,
527                   const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
528                   extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override;
529     result do_in(state_type& __st,
530                  const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
531                  intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const override;
532     result do_unshift(state_type& __st,
533                       extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override;
534     int do_encoding() const _NOEXCEPT override;
535     bool do_always_noconv() const _NOEXCEPT override;
536     int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const override;
537     int do_max_length() const _NOEXCEPT override;
538};
539
540_LIBCPP_SUPPRESS_DEPRECATED_PUSH
541template <class _Elem, unsigned long _Maxcode = 0x10ffff,
542          codecvt_mode _Mode = (codecvt_mode)0>
543class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 codecvt_utf8_utf16
544    : public __codecvt_utf8_utf16<_Elem>
545{
546public:
547    _LIBCPP_HIDE_FROM_ABI
548    explicit codecvt_utf8_utf16(size_t __refs = 0)
549        : __codecvt_utf8_utf16<_Elem>(__refs, _Maxcode, _Mode) {}
550
551    _LIBCPP_HIDE_FROM_ABI
552    ~codecvt_utf8_utf16() {}
553};
554_LIBCPP_SUPPRESS_DEPRECATED_POP
555
556_LIBCPP_END_NAMESPACE_STD
557
558#endif // _LIBCPP_STD_VER < 26 || defined(_LIBCPP_BUILDING_LIBRARY) || defined(_LIBCPP_ENABLE_CXX26_REMOVED_CODECVT)
559
560#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
561#  include <atomic>
562#  include <concepts>
563#  include <cstddef>
564#  include <cstdlib>
565#  include <cstring>
566#  include <initializer_list>
567#  include <iosfwd>
568#  include <limits>
569#  include <mutex>
570#  include <new>
571#  include <stdexcept>
572#  include <type_traits>
573#  include <typeinfo>
574#endif
575
576#endif // _LIBCPP_CODECVT
577