From 8dcb1de91e15ff7fc66279cd9cd9ad8a70f624e0 Mon Sep 17 00:00:00 2001 From: Dominick Allen Date: Tue, 29 Oct 2024 23:16:46 -0500 Subject: u8 string literals --- include/fud_format.hpp | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) (limited to 'include/fud_format.hpp') diff --git a/include/fud_format.hpp b/include/fud_format.hpp index c06643d..4d38c26 100644 --- a/include/fud_format.hpp +++ b/include/fud_format.hpp @@ -24,7 +24,7 @@ #include "fud_option.hpp" #include "fud_result.hpp" #include "fud_status.hpp" -#include "fud_string.hpp" +#include "fud_string.hpp" // IWYU pragma: keep #include "fud_string_convert.hpp" #include "fud_string_view.hpp" #include "fud_utf8.hpp" @@ -42,18 +42,18 @@ constexpr size_t maxIntCharCount = bitsPerOctal * sizeof(uint64_t) + 4; struct FormatString { template - consteval FormatString(const char (&input)[N]) : m_size{N - 1}, m_data{input} + consteval FormatString(const utf8 (&input)[N]) : m_size{N - 1}, m_data{input} { static_assert(N > 0); } StringView view() { - return StringView{m_size, reinterpret_cast(m_data)}; + return StringView{m_size, m_data}; } size_t m_size; - const char* m_data; + const utf8* m_data; }; struct FormatAlign { @@ -1127,7 +1127,7 @@ void fillScientificBuffer(IntCharArray& buffer, Significand significand, uint8_t } } - forEach(Span{buffer.data(), bufferLength}, [&](uint8_t digit) { + forEach(Span{buffer.data(), bufferLength}, [&](uint8_t digit) { return static_cast(digit + '0'); }); @@ -1485,17 +1485,6 @@ FormatResult format(Sink& sink, FormatCharMode formatMode, const FormatSpec& for return result; } -namespace fudTest { -inline void test() -{ - StringView prefix{0, ""}; - String sink{}; - - static_cast(format(sink, FormatCharMode::Unchecked, "HELL YEAH")); - static_cast(format(sink, FormatCharMode::Unchecked, "HELL YEAH", 1, true, "ye")); -} -} // namespace fudTest - } // namespace fud #endif -- cgit v1.2.3