diff options
author | Steven Le Rouzic <steven.lerouzic@gmail.com> | 2024-11-13 23:58:18 +0100 |
---|---|---|
committer | Steven Le Rouzic <steven.lerouzic@gmail.com> | 2024-12-20 15:35:58 +0100 |
commit | 75e956eac30050bb10d131b8f14ecbc396abcf17 (patch) | |
tree | 116bef4e8208506cbb17dcf40006ed379cc6f0c1 /asl/format.hpp | |
parent | ae9d36675a21b5a81bc87279dc9ee1224cdcb963 (diff) |
Use string_view for formatting
Diffstat (limited to 'asl/format.hpp')
-rw-r--r-- | asl/format.hpp | 11 |
1 files changed, 5 insertions, 6 deletions
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<const type_erased_arg> args);
+void format(writer*, string_view fmt, span<const type_erased_arg> 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<const char>(s, len)));
+ m_writer->write(as_bytes(s.as_span()));
}
};
-// @Todo Use string_view
template<formattable... Args>
-void format(writer* w, const char* fmt, const Args&... args)
+void format(writer* w, string_view fmt, const Args&... args)
{
if constexpr (types_count<Args...> > 0)
{
|