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___FORMAT_UNICODE_H
11#define _LIBCPP___FORMAT_UNICODE_H
12
13#include <__assert>
14#include <__bit/countl.h>
15#include <__concepts/same_as.h>
16#include <__config>
17#include <__format/extended_grapheme_cluster_table.h>
18#include <__format/indic_conjunct_break_table.h>
19#include <__iterator/concepts.h>
20#include <__iterator/readable_traits.h> // iter_value_t
21#include <__utility/unreachable.h>
22#include <string_view>
23
24#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
25# pragma GCC system_header
26#endif
27
28_LIBCPP_BEGIN_NAMESPACE_STD
29
30#if _LIBCPP_STD_VER >= 20
31
32namespace __unicode {
33
34// Helper struct for the result of a consume operation.
35//
36// The status value for a correct code point is 0. This allows a valid value to
37// be used without masking.
38// When the decoding fails it know the number of code units affected. For the
39// current use-cases that value is not needed, therefore it is not stored.
40// The escape routine needs the number of code units for both a valid and
41// invalid character and keeps track of it itself. Doing it in this result
42// unconditionally would give some overhead when the value is unneeded.
43struct __consume_result {
44 // When __status == __ok it contains the decoded code point.
45 // Else it contains the replacement character U+FFFD
46 char32_t __code_point : 31;
47
48 enum : char32_t {
49 // Consumed a well-formed code point.
50 __ok = 0,
51 // Encountered invalid UTF-8
52 __error = 1
53 } __status : 1 {__ok};
54};
55static_assert(sizeof(__consume_result) == sizeof(char32_t));
56
57# if _LIBCPP_HAS_UNICODE
58
59/// Implements the grapheme cluster boundary rules
60///
61/// These rules are used to implement format's width estimation as stated in
62/// [format.string.std]/11
63///
64/// The Standard refers to UAX \#29 for Unicode 12.0.0
65/// https://www.unicode.org/reports/tr29/#Grapheme_Cluster_Boundary_Rules
66///
67/// The data tables used are
68/// https://www.unicode.org/Public/UCD/latest/ucd/auxiliary/GraphemeBreakProperty.txt
69/// https://www.unicode.org/Public/UCD/latest/ucd/emoji/emoji-data.txt
70/// https://www.unicode.org/Public/UCD/latest/ucd/auxiliary/GraphemeBreakTest.txt (for testing only)
71
72inline constexpr char32_t __replacement_character = U'\ufffd';
73
74// The error of a consume operation.
75//
76// This sets the code point to the replacement character. This code point does
77// not participate in the grapheme clustering, so grapheme clustering code can
78// ignore the error status and always use the code point.
79inline constexpr __consume_result __consume_result_error{__replacement_character, __consume_result::__error};
80
81[[nodiscard]] constexpr bool __is_high_surrogate(char32_t __value) { return __value >= 0xd800 && __value <= 0xdbff; }
82
83[[nodiscard]] constexpr bool __is_low_surrogate(char32_t __value) { return __value >= 0xdc00 && __value <= 0xdfff; }
84
85// https://www.unicode.org/glossary/#surrogate_code_point
86[[nodiscard]] inline constexpr bool __is_surrogate(char32_t __value) { return __value >= 0xd800 && __value <= 0xdfff; }
87
88// https://www.unicode.org/glossary/#code_point
89[[nodiscard]] inline constexpr bool __is_code_point(char32_t __value) { return __value <= 0x10ffff; }
90
91// https://www.unicode.org/glossary/#unicode_scalar_value
92[[nodiscard]] inline constexpr bool __is_scalar_value(char32_t __value) {
93 return __unicode::__is_code_point(__value) && !__unicode::__is_surrogate(__value);
94}
95
96template <class _Iterator>
97 requires same_as<iter_value_t<_Iterator>, char>
98constexpr bool __is_continuation(_Iterator __char, int __count) {
99 do {
100 if ((*__char & 0b1100'0000) != 0b1000'0000)
101 return false;
102 --__count;
103 ++__char;
104 } while (__count);
105 return true;
106}
107
108/// Helper class to extract a code unit from a Unicode character range.
109///
110/// The stored range is a view. There are multiple specialization for different
111/// character types.
112template <class _CharT>
113class __code_point_view;
114
115/// UTF-8 specialization.
116template <>
117class __code_point_view<char> {
118 using _Iterator _LIBCPP_NODEBUG = basic_string_view<char>::const_iterator;
119
120public:
121 constexpr explicit __code_point_view(_Iterator __first, _Iterator __last) : __first_(__first), __last_(__last) {}
122
123 constexpr bool __at_end() const noexcept { return __first_ == __last_; }
124 constexpr _Iterator __position() const noexcept { return __first_; }
125
126 // https://www.unicode.org/versions/latest/ch03.pdf#G7404
127 // Based on Table 3-7, Well-Formed UTF-8 Byte Sequences
128 //
129 // Code Points First Byte Second Byte Third Byte Fourth Byte Remarks
130 // U+0000..U+007F 00..7F U+0000..U+007F 1 code unit range
131 // C0..C1 80..BF invalid overlong encoding
132 // U+0080..U+07FF C2..DF 80..BF U+0080..U+07FF 2 code unit range
133 // E0 80..9F 80..BF invalid overlong encoding
134 // U+0800..U+0FFF E0 A0..BF 80..BF U+0800..U+FFFF 3 code unit range
135 // U+1000..U+CFFF E1..EC 80..BF 80..BF
136 // U+D000..U+D7FF ED 80..9F 80..BF
137 // U+D800..U+DFFF ED A0..BF 80..BF invalid encoding of surrogate code point
138 // U+E000..U+FFFF EE..EF 80..BF 80..BF
139 // F0 80..8F 80..BF 80..BF invalid overlong encoding
140 // U+10000..U+3FFFF F0 90..BF 80..BF 80..BF U+10000..U+10FFFF 4 code unit range
141 // U+40000..U+FFFFF F1..F3 80..BF 80..BF 80..BF
142 // U+100000..U+10FFFF F4 80..8F 80..BF 80..BF
143 // F4 90..BF 80..BF 80..BF U+110000.. invalid code point range
144 //
145 // Unlike other parsers, these invalid entries are tested after decoding.
146 // - The parser always needs to consume these code units
147 // - The code is optimized for well-formed UTF-8
148 [[nodiscard]] constexpr __consume_result __consume() noexcept {
149 _LIBCPP_ASSERT_INTERNAL(__first_ != __last_, "can't move beyond the end of input");
150
151 // Based on the number of leading 1 bits the number of code units in the
152 // code point can be determined. See
153 // https://en.wikipedia.org/wiki/UTF-8#Encoding
154 switch (std::countl_one(t: static_cast<unsigned char>(*__first_))) {
155 case 0:
156 return {static_cast<unsigned char>(*__first_++)};
157
158 case 2: {
159 if (__last_ - __first_ < 2 || !__unicode::__is_continuation(char: __first_ + 1, count: 1)) [[unlikely]]
160 break;
161
162 char32_t __value = static_cast<unsigned char>(*__first_++) & 0x1f;
163 __value <<= 6;
164 __value |= static_cast<unsigned char>(*__first_++) & 0x3f;
165
166 // These values should be encoded in 1 UTF-8 code unit.
167 if (__value < 0x0080) [[unlikely]]
168 return __consume_result_error;
169
170 return {__value};
171 }
172
173 case 3: {
174 if (__last_ - __first_ < 3 || !__unicode::__is_continuation(char: __first_ + 1, count: 2)) [[unlikely]]
175 break;
176
177 char32_t __value = static_cast<unsigned char>(*__first_++) & 0x0f;
178 __value <<= 6;
179 __value |= static_cast<unsigned char>(*__first_++) & 0x3f;
180 __value <<= 6;
181 __value |= static_cast<unsigned char>(*__first_++) & 0x3f;
182
183 // These values should be encoded in 1 or 2 UTF-8 code units.
184 if (__value < 0x0800) [[unlikely]]
185 return __consume_result_error;
186
187 // A surrogate value is always encoded in 3 UTF-8 code units.
188 if (__unicode::__is_surrogate(__value)) [[unlikely]]
189 return __consume_result_error;
190
191 return {__value};
192 }
193
194 case 4: {
195 if (__last_ - __first_ < 4 || !__unicode::__is_continuation(char: __first_ + 1, count: 3)) [[unlikely]]
196 break;
197
198 char32_t __value = static_cast<unsigned char>(*__first_++) & 0x07;
199 __value <<= 6;
200 __value |= static_cast<unsigned char>(*__first_++) & 0x3f;
201 __value <<= 6;
202 __value |= static_cast<unsigned char>(*__first_++) & 0x3f;
203 __value <<= 6;
204 __value |= static_cast<unsigned char>(*__first_++) & 0x3f;
205
206 // These values should be encoded in 1, 2, or 3 UTF-8 code units.
207 if (__value < 0x10000) [[unlikely]]
208 return __consume_result_error;
209
210 // A value too large is always encoded in 4 UTF-8 code units.
211 if (!__unicode::__is_code_point(__value)) [[unlikely]]
212 return __consume_result_error;
213
214 return {__value};
215 }
216 }
217 // An invalid number of leading ones can be garbage or a code unit in the
218 // middle of a code point. By consuming one code unit the parser may get
219 // "in sync" after a few code units.
220 ++__first_;
221 return __consume_result_error;
222 }
223
224private:
225 _Iterator __first_;
226 _Iterator __last_;
227};
228
229# if _LIBCPP_HAS_WIDE_CHARACTERS
230constexpr bool __is_surrogate_pair_high(wchar_t __value) { return __value >= 0xd800 && __value <= 0xdbff; }
231
232constexpr bool __is_surrogate_pair_low(wchar_t __value) { return __value >= 0xdc00 && __value <= 0xdfff; }
233
234/// This specialization depends on the size of wchar_t
235/// - 2 UTF-16 (for example Windows and AIX)
236/// - 4 UTF-32 (for example Linux)
237template <>
238class __code_point_view<wchar_t> {
239 using _Iterator _LIBCPP_NODEBUG = typename basic_string_view<wchar_t>::const_iterator;
240
241public:
242 static_assert(sizeof(wchar_t) == 2 || sizeof(wchar_t) == 4, "sizeof(wchar_t) has a not implemented value");
243
244 constexpr explicit __code_point_view(_Iterator __first, _Iterator __last) : __first_(__first), __last_(__last) {}
245
246 constexpr _Iterator __position() const noexcept { return __first_; }
247 constexpr bool __at_end() const noexcept { return __first_ == __last_; }
248
249 [[nodiscard]] constexpr __consume_result __consume() noexcept {
250 _LIBCPP_ASSERT_INTERNAL(__first_ != __last_, "can't move beyond the end of input");
251
252 char32_t __value = static_cast<char32_t>(*__first_++);
253 if constexpr (sizeof(wchar_t) == 2) {
254 if (__unicode::__is_low_surrogate(__value)) [[unlikely]]
255 return __consume_result_error;
256
257 if (__unicode::__is_high_surrogate(__value)) {
258 if (__first_ == __last_ || !__unicode::__is_low_surrogate(value: static_cast<char32_t>(*__first_))) [[unlikely]]
259 return __consume_result_error;
260
261 __value -= 0xd800;
262 __value <<= 10;
263 __value += static_cast<char32_t>(*__first_++) - 0xdc00;
264 __value += 0x10000;
265
266 if (!__unicode::__is_code_point(__value)) [[unlikely]]
267 return __consume_result_error;
268 }
269 } else {
270 if (!__unicode::__is_scalar_value(__value)) [[unlikely]]
271 return __consume_result_error;
272 }
273
274 return {__value};
275 }
276
277private:
278 _Iterator __first_;
279 _Iterator __last_;
280};
281# endif // _LIBCPP_HAS_WIDE_CHARACTERS
282
283// State machine to implement the Extended Grapheme Cluster Boundary
284//
285// The exact rules may change between Unicode versions.
286// This implements the extended rules see
287// https://www.unicode.org/reports/tr29/#Grapheme_Cluster_Boundaries
288class __extended_grapheme_cluster_break {
289 using __EGC_property _LIBCPP_NODEBUG = __extended_grapheme_custer_property_boundary::__property;
290 using __inCB_property _LIBCPP_NODEBUG = __indic_conjunct_break::__property;
291
292public:
293 constexpr explicit __extended_grapheme_cluster_break(char32_t __first_code_point)
294 : __prev_code_point_(__first_code_point),
295 __prev_property_(__extended_grapheme_custer_property_boundary::__get_property(code_point: __first_code_point)) {
296 // Initializes the active rule.
297 if (__prev_property_ == __EGC_property::__Extended_Pictographic)
298 __active_rule_ = __rule::__GB11_emoji;
299 else if (__prev_property_ == __EGC_property::__Regional_Indicator)
300 __active_rule_ = __rule::__GB12_GB13_regional_indicator;
301 else if (__indic_conjunct_break::__get_property(code_point: __first_code_point) == __inCB_property::__Consonant)
302 __active_rule_ = __rule::__GB9c_indic_conjunct_break;
303 }
304
305 [[nodiscard]] constexpr bool operator()(char32_t __next_code_point) {
306 __EGC_property __next_property = __extended_grapheme_custer_property_boundary::__get_property(code_point: __next_code_point);
307 bool __result = __evaluate(__next_code_point, __next_property);
308 __prev_code_point_ = __next_code_point;
309 __prev_property_ = __next_property;
310 return __result;
311 }
312
313 // The code point whose break propery are considered during the next
314 // evaluation cyle.
315 [[nodiscard]] constexpr char32_t __current_code_point() const { return __prev_code_point_; }
316
317private:
318 // The naming of the identifiers matches the Unicode standard.
319 // NOLINTBEGIN(readability-identifier-naming)
320
321 [[nodiscard]] constexpr bool __evaluate(char32_t __next_code_point, __EGC_property __next_property) {
322 switch (__active_rule_) {
323 case __rule::__none:
324 return __evaluate_none(__next_code_point, __next_property);
325 case __rule::__GB9c_indic_conjunct_break:
326 return __evaluate_GB9c_indic_conjunct_break(__next_code_point, __next_property);
327 case __rule::__GB11_emoji:
328 return __evaluate_GB11_emoji(__next_code_point, __next_property);
329 case __rule::__GB12_GB13_regional_indicator:
330 return __evaluate_GB12_GB13_regional_indicator(__next_code_point, __next_property);
331 }
332 __libcpp_unreachable();
333 }
334
335 constexpr bool __evaluate_none(char32_t __next_code_point, __EGC_property __next_property) {
336 // *** Break at the start and end of text, unless the text is empty. ***
337
338 _LIBCPP_ASSERT_INTERNAL(__prev_property_ != __EGC_property::__sot, "should be handled in the constructor"); // GB1
339 _LIBCPP_ASSERT_INTERNAL(__prev_property_ != __EGC_property::__eot, "should be handled by our caller"); // GB2
340
341 // *** Do not break between a CR and LF. Otherwise, break before and after controls. ***
342 if (__prev_property_ == __EGC_property::__CR && __next_property == __EGC_property::__LF) // GB3
343 return false;
344
345 if (__prev_property_ == __EGC_property::__Control || __prev_property_ == __EGC_property::__CR ||
346 __prev_property_ == __EGC_property::__LF) // GB4
347 return true;
348
349 if (__next_property == __EGC_property::__Control || __next_property == __EGC_property::__CR ||
350 __next_property == __EGC_property::__LF) // GB5
351 return true;
352
353 // *** Do not break Hangul syllable sequences. ***
354 if (__prev_property_ == __EGC_property::__L &&
355 (__next_property == __EGC_property::__L || __next_property == __EGC_property::__V ||
356 __next_property == __EGC_property::__LV || __next_property == __EGC_property::__LVT)) // GB6
357 return false;
358
359 if ((__prev_property_ == __EGC_property::__LV || __prev_property_ == __EGC_property::__V) &&
360 (__next_property == __EGC_property::__V || __next_property == __EGC_property::__T)) // GB7
361 return false;
362
363 if ((__prev_property_ == __EGC_property::__LVT || __prev_property_ == __EGC_property::__T) &&
364 __next_property == __EGC_property::__T) // GB8
365 return false;
366
367 // *** Do not break before extending characters or ZWJ. ***
368 if (__next_property == __EGC_property::__Extend || __next_property == __EGC_property::__ZWJ)
369 return false; // GB9
370
371 // *** Do not break before SpacingMarks, or after Prepend characters. ***
372 if (__next_property == __EGC_property::__SpacingMark) // GB9a
373 return false;
374
375 if (__prev_property_ == __EGC_property::__Prepend) // GB9b
376 return false;
377
378 // *** Do not break within certain combinations with Indic_Conjunct_Break (InCB)=Linker. ***
379 if (__indic_conjunct_break::__get_property(code_point: __next_code_point) == __inCB_property::__Consonant) {
380 __active_rule_ = __rule::__GB9c_indic_conjunct_break;
381 __GB9c_indic_conjunct_break_state_ = __GB9c_indic_conjunct_break_state::__Consonant;
382 return true;
383 }
384
385 // *** Do not break within emoji modifier sequences or emoji zwj sequences. ***
386 if (__next_property == __EGC_property::__Extended_Pictographic) {
387 __active_rule_ = __rule::__GB11_emoji;
388 __GB11_emoji_state_ = __GB11_emoji_state::__Extended_Pictographic;
389 return true;
390 }
391
392 // *** Do not break within emoji flag sequences ***
393
394 // That is, do not break between regional indicator (RI) symbols if there
395 // is an odd number of RI characters before the break point.
396 if (__next_property == __EGC_property::__Regional_Indicator) { // GB12 + GB13
397 __active_rule_ = __rule::__GB12_GB13_regional_indicator;
398 return true;
399 }
400
401 // *** Otherwise, break everywhere. ***
402 return true; // GB999
403 }
404
405 [[nodiscard]] constexpr bool
406 __evaluate_GB9c_indic_conjunct_break(char32_t __next_code_point, __EGC_property __next_property) {
407 __inCB_property __break = __indic_conjunct_break::__get_property(code_point: __next_code_point);
408 if (__break == __inCB_property::__none) {
409 __active_rule_ = __rule::__none;
410 return __evaluate_none(__next_code_point, __next_property);
411 }
412
413 switch (__GB9c_indic_conjunct_break_state_) {
414 case __GB9c_indic_conjunct_break_state::__Consonant:
415 if (__break == __inCB_property::__Extend) {
416 return false;
417 }
418 if (__break == __inCB_property::__Linker) {
419 __GB9c_indic_conjunct_break_state_ = __GB9c_indic_conjunct_break_state::__Linker;
420 return false;
421 }
422 __active_rule_ = __rule::__none;
423 return __evaluate_none(__next_code_point, __next_property);
424
425 case __GB9c_indic_conjunct_break_state::__Linker:
426 if (__break == __inCB_property::__Extend) {
427 return false;
428 }
429 if (__break == __inCB_property::__Linker) {
430 return false;
431 }
432 if (__break == __inCB_property::__Consonant) {
433 __GB9c_indic_conjunct_break_state_ = __GB9c_indic_conjunct_break_state::__Consonant;
434 return false;
435 }
436 __active_rule_ = __rule::__none;
437 return __evaluate_none(__next_code_point, __next_property);
438 }
439 __libcpp_unreachable();
440 }
441
442 [[nodiscard]] constexpr bool __evaluate_GB11_emoji(char32_t __next_code_point, __EGC_property __next_property) {
443 switch (__GB11_emoji_state_) {
444 case __GB11_emoji_state::__Extended_Pictographic:
445 if (__next_property == __EGC_property::__Extend) {
446 __GB11_emoji_state_ = __GB11_emoji_state::__Extend;
447 return false;
448 }
449 [[fallthrough]];
450 case __GB11_emoji_state::__Extend:
451 if (__next_property == __EGC_property::__ZWJ) {
452 __GB11_emoji_state_ = __GB11_emoji_state::__ZWJ;
453 return false;
454 }
455 if (__next_property == __EGC_property::__Extend)
456 return false;
457 __active_rule_ = __rule::__none;
458 return __evaluate_none(__next_code_point, __next_property);
459
460 case __GB11_emoji_state::__ZWJ:
461 if (__next_property == __EGC_property::__Extended_Pictographic) {
462 __GB11_emoji_state_ = __GB11_emoji_state::__Extended_Pictographic;
463 return false;
464 }
465 __active_rule_ = __rule::__none;
466 return __evaluate_none(__next_code_point, __next_property);
467 }
468 __libcpp_unreachable();
469 }
470
471 [[nodiscard]] constexpr bool
472 __evaluate_GB12_GB13_regional_indicator(char32_t __next_code_point, __EGC_property __next_property) {
473 __active_rule_ = __rule::__none;
474 if (__next_property == __EGC_property::__Regional_Indicator)
475 return false;
476 return __evaluate_none(__next_code_point, __next_property);
477 }
478
479 char32_t __prev_code_point_;
480 __EGC_property __prev_property_;
481
482 enum class __rule {
483 __none,
484 __GB9c_indic_conjunct_break,
485 __GB11_emoji,
486 __GB12_GB13_regional_indicator,
487 };
488 __rule __active_rule_ = __rule::__none;
489
490 enum class __GB11_emoji_state {
491 __Extended_Pictographic,
492 __Extend,
493 __ZWJ,
494 };
495 __GB11_emoji_state __GB11_emoji_state_ = __GB11_emoji_state::__Extended_Pictographic;
496
497 enum class __GB9c_indic_conjunct_break_state {
498 __Consonant,
499 __Linker,
500 };
501
502 __GB9c_indic_conjunct_break_state __GB9c_indic_conjunct_break_state_ = __GB9c_indic_conjunct_break_state::__Consonant;
503
504 // NOLINTEND(readability-identifier-naming)
505};
506
507/// Helper class to extract an extended grapheme cluster from a Unicode character range.
508///
509/// This function is used to determine the column width of an extended grapheme
510/// cluster. In order to do that only the first code point is evaluated.
511/// Therefore only this code point is extracted.
512template <class _CharT>
513class __extended_grapheme_cluster_view {
514 using _Iterator _LIBCPP_NODEBUG = typename basic_string_view<_CharT>::const_iterator;
515
516public:
517 constexpr explicit __extended_grapheme_cluster_view(_Iterator __first, _Iterator __last)
518 : __code_point_view_(__first, __last), __at_break_(__code_point_view_.__consume().__code_point) {}
519
520 struct __cluster {
521 /// The first code point of the extended grapheme cluster.
522 ///
523 /// The first code point is used to estimate the width of the extended
524 /// grapheme cluster.
525 char32_t __code_point_;
526
527 /// Points one beyond the last code unit in the extended grapheme cluster.
528 ///
529 /// It's expected the caller has the start position and thus can determine
530 /// the code unit range of the extended grapheme cluster.
531 _Iterator __last_;
532 };
533
534 [[nodiscard]] constexpr __cluster __consume() {
535 char32_t __code_point = __at_break_.__current_code_point();
536 _Iterator __position = __code_point_view_.__position();
537 while (!__code_point_view_.__at_end()) {
538 if (__at_break_(__code_point_view_.__consume().__code_point))
539 break;
540 __position = __code_point_view_.__position();
541 }
542 return {__code_point, __position};
543 }
544
545private:
546 __code_point_view<_CharT> __code_point_view_;
547 __extended_grapheme_cluster_break __at_break_;
548};
549
550template <contiguous_iterator _Iterator>
551__extended_grapheme_cluster_view(_Iterator, _Iterator) -> __extended_grapheme_cluster_view<iter_value_t<_Iterator>>;
552
553# else // _LIBCPP_HAS_UNICODE
554
555// For ASCII every character is a "code point".
556// This makes it easier to write code agnostic of the _LIBCPP_HAS_UNICODE define.
557template <class _CharT>
558class __code_point_view {
559 using _Iterator _LIBCPP_NODEBUG = typename basic_string_view<_CharT>::const_iterator;
560
561public:
562 constexpr explicit __code_point_view(_Iterator __first, _Iterator __last) : __first_(__first), __last_(__last) {}
563
564 constexpr bool __at_end() const noexcept { return __first_ == __last_; }
565 constexpr _Iterator __position() const noexcept { return __first_; }
566
567 [[nodiscard]] constexpr __consume_result __consume() noexcept {
568 _LIBCPP_ASSERT_INTERNAL(__first_ != __last_, "can't move beyond the end of input");
569 return {static_cast<char32_t>(*__first_++)};
570 }
571
572private:
573 _Iterator __first_;
574 _Iterator __last_;
575};
576
577# endif // _LIBCPP_HAS_UNICODE
578
579} // namespace __unicode
580
581#endif // _LIBCPP_STD_VER >= 20
582
583_LIBCPP_END_NAMESPACE_STD
584
585#endif // _LIBCPP___FORMAT_UNICODE_H
586