2525
2626#include < iris/bits/specialization_of.hpp>
2727
28+ #include < concepts>
29+ #include < ostream>
30+ #include < format>
31+ #include < ranges>
2832#include < print>
2933#include < iterator>
3034#include < memory>
@@ -147,6 +151,15 @@ inline void print_chars(std::ostream& os, char32_t const ch)
147151 iris::unicode::append8 (ch, std::ostreambuf_iterator (os));
148152}
149153
154+ template <std::ranges::forward_range R>
155+ requires std::same_as<std::ranges::range_value_t <R>, char32_t >
156+ void print_chars (std::ostream& os, R const & chars)
157+ {
158+ for (char32_t ch : chars) {
159+ x4::print_chars (os, ch);
160+ }
161+ }
162+
150163template <std::forward_iterator It, std::sentinel_for<It> Se>
151164void print_chars (std::ostream& os, It it, Se const se, std::size_t const max_code_points)
152165{
@@ -234,11 +247,14 @@ struct print_attribute_debug
234247 if (!ptr) {
235248 out << " nullptr" ;
236249 } else {
237- print_attribute_debug< typename std::pointer_traits<T>::element_type>:: call (out, *ptr);
250+ x4::print_attribute (out, *ptr);
238251 }
239252
240253 } else if constexpr (std::formattable<T, char >) {
241- std::format_to (std::ostreambuf_iterator{out}, " {}" , val);
254+ x4::print_chars (out, iris::unicode::transcode<char32_t >(std::format (" {}" , val)));
255+
256+ } else if constexpr (iris::StringLike<T>) {
257+ x4::print_chars (out, iris::unicode::transcode_ref<char32_t >(val));
242258
243259 } else {
244260 // TODO: https://github.com/iris-cpp/iris/issues/51
@@ -260,7 +276,7 @@ struct print_attribute_debug
260276 static void call (std::ostream& out, T_ const & val)
261277 {
262278 if constexpr (iris::StringLike<T_ >) {
263- out << iris::unicode::transcode_ref<char >(std::basic_string_view{ val} );
279+ x4::print_chars ( out, iris::unicode::transcode_ref<char32_t >( val) );
264280
265281 } else {
266282 out << ' [' ;
0 commit comments