@@ -179,7 +179,7 @@ namespace sysstr
179179 m_decoder.put (byte);
180180 if (m_decoder.done ())
181181 {
182- output (char32_t {m_decoder. value ( )});
182+ output (char32_t {SYS_STRING_DECODER_VALUE (m_decoder )});
183183 return ;
184184 }
185185 if (m_decoder.error ())
@@ -202,7 +202,7 @@ namespace sysstr
202202 m_decoder.put (uint16_t (c));
203203 if (m_decoder.done ())
204204 {
205- output (char32_t {m_decoder. value ( )});
205+ output (char32_t {SYS_STRING_DECODER_VALUE (m_decoder )});
206206 return ;
207207 }
208208 if (m_decoder.error ())
@@ -222,7 +222,7 @@ namespace sysstr
222222 void put(Char c) noexcept (noexcept (this ->output (char32_t {}))) requires(From == utf32)
223223 {
224224 if (m_decoder.put (uint32_t (c)))
225- output (char32_t {m_decoder. value ( )});
225+ output (char32_t {SYS_STRING_DECODER_VALUE (m_decoder )});
226226 else
227227 output (char32_t {U' \uFFFD ' });
228228 }
@@ -284,7 +284,7 @@ namespace sysstr
284284 return char32_t {U' \uFFFD ' };
285285 ++first;
286286 if (decoder.done ())
287- return char32_t {decoder. value ( )};
287+ return char32_t {SYS_STRING_DECODER_VALUE (decoder )};
288288 if (first == last)
289289 return char32_t {U' \uFFFD ' };
290290 }
@@ -296,7 +296,7 @@ namespace sysstr
296296 decoder.put (uint16_t (*first));
297297 ++first;
298298 if (decoder.done ())
299- return char32_t {decoder. value ( )};
299+ return char32_t {SYS_STRING_DECODER_VALUE (decoder )};
300300
301301 if (decoder.error () || first == last)
302302 return char32_t {U' \uFFFD ' };
@@ -306,14 +306,14 @@ namespace sysstr
306306 return char32_t {U' \uFFFD ' };
307307 ++first;
308308
309- return char32_t {decoder. value ( )};
309+ return char32_t {SYS_STRING_DECODER_VALUE (decoder )};
310310 }
311311 else if constexpr (From == utf32)
312312 {
313313 utf_codepoint_decoder<utf32> decoder;
314314 bool res = decoder.put (uint32_t (*first));
315315 ++first;
316- return res ? char32_t {decoder. value ( )} : U' \uFFFD ' ;
316+ return res ? char32_t {SYS_STRING_DECODER_VALUE (decoder )} : U' \uFFFD ' ;
317317 }
318318
319319
@@ -346,7 +346,7 @@ namespace sysstr
346346 decoder.put (byte);
347347
348348 if (decoder.done ())
349- return char32_t {decoder. value ( )};
349+ return char32_t {SYS_STRING_DECODER_VALUE (decoder )};
350350
351351 if (decoder.error ())
352352 {
@@ -368,7 +368,7 @@ namespace sysstr
368368 return char32_t {U' \uFFFD ' };
369369 ++first;
370370 if (decoder.done ())
371- return char32_t {decoder. value ( )};
371+ return char32_t {SYS_STRING_DECODER_VALUE (decoder )};
372372 if (first == last)
373373 return char32_t {U' \uFFFD ' };
374374 }
@@ -381,7 +381,7 @@ namespace sysstr
381381 decoder.put (uint16_t (*first));
382382 ++first;
383383 if (decoder.done ())
384- return char32_t {decoder. value ( )};
384+ return char32_t {SYS_STRING_DECODER_VALUE (decoder )};
385385
386386 if (decoder.error () || first == last)
387387 return char32_t {U' \uFFFD ' };
@@ -391,14 +391,40 @@ namespace sysstr
391391 return char32_t {U' \uFFFD ' };
392392 ++first;
393393
394- return char32_t {decoder. value ( )};
394+ return char32_t {SYS_STRING_DECODER_VALUE (decoder )};
395395 }
396396 else if constexpr (From == utf32)
397397 {
398398 return utf32_input::read (first, last);
399399 }
400400 }
401401
402+ template <util::ct_string Str>
403+ consteval auto ct_utf8_to_utf32 () {
404+ constexpr size_t size = []() {
405+ utf_codepoint_decoder<utf8> decoder;
406+ size_t size = 0 ;
407+ for (auto c: Str.chars )
408+ {
409+ decoder.put (c);
410+ if (decoder.error ())
411+ throw " invalid UTF-8 constant" ;
412+ size += decoder.done ();
413+ }
414+ return size;
415+ }();
416+ utf_codepoint_decoder<utf8> decoder;
417+ char32_t ret[size];
418+ size_t idx = 0 ;
419+ for (auto c: Str.chars )
420+ {
421+ decoder.put (c);
422+ if (decoder.done ())
423+ ret[idx++] = SYS_STRING_DECODER_VALUE (decoder);
424+ }
425+ return util::ct_string<char32_t , size>(ret);
426+ }
427+
402428 template <util::ct_string Str>
403429 consteval auto ct_utf8_to_utf16 () {
404430 constexpr size_t size = []() {
@@ -412,7 +438,7 @@ namespace sysstr
412438 throw " invalid UTF-8 constant" ;
413439 if (decoder.done ())
414440 {
415- encoder.put (decoder. value ( ));
441+ encoder.put (SYS_STRING_DECODER_VALUE (decoder ));
416442 size += encoder.size ();
417443 }
418444 }
@@ -427,7 +453,7 @@ namespace sysstr
427453 decoder.put (c);
428454 if (decoder.done ())
429455 {
430- encoder.put (decoder. value ( ));
456+ encoder.put (SYS_STRING_DECODER_VALUE (decoder ));
431457 for (char16_t uc: encoder)
432458 ret[idx++] = uc;
433459 }
0 commit comments