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