From 75e956eac30050bb10d131b8f14ecbc396abcf17 Mon Sep 17 00:00:00 2001 From: Steven Le Rouzic Date: Wed, 13 Nov 2024 23:58:18 +0100 Subject: Use string_view for formatting --- asl/format.hpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'asl/format.hpp') diff --git a/asl/format.hpp b/asl/format.hpp index 666e325..57be45d 100644 --- a/asl/format.hpp +++ b/asl/format.hpp @@ -4,6 +4,7 @@ #include "asl/meta.hpp" #include "asl/io.hpp" #include "asl/span.hpp" +#include "asl/string_view.hpp" namespace asl { @@ -37,7 +38,7 @@ struct type_erased_arg {} }; -void format(writer*, const char* fmt, span args); +void format(writer*, string_view fmt, span args); } // namespace internals @@ -50,16 +51,14 @@ public: : m_writer{writer} {} - // @Todo Use string_view - constexpr void write(const char* s, isize_t len) + constexpr void write(string_view s) { - m_writer->write(as_bytes(span(s, len))); + m_writer->write(as_bytes(s.as_span())); } }; -// @Todo Use string_view template -void format(writer* w, const char* fmt, const Args&... args) +void format(writer* w, string_view fmt, const Args&... args) { if constexpr (types_count > 0) { -- cgit