From aa49abdf239bae6065fddd0839ec67a404c9748c Mon Sep 17 00:00:00 2001 From: Joel Klinghed Date: Mon, 15 Sep 2025 21:15:53 +0200 Subject: Add .clang-format Make it easier to keep a consistent style --- src/u16.hh | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) (limited to 'src/u16.hh') diff --git a/src/u16.hh b/src/u16.hh index d6a3672..70ba157 100644 --- a/src/u16.hh +++ b/src/u16.hh @@ -1,9 +1,9 @@ #ifndef U16_HH #define U16_HH -#include "u.hh" // IWYU pragma: export +#include "u.hh" // IWYU pragma: export -#include // IWYU pragma: export +#include // IWYU pragma: export #include #include #include @@ -11,10 +11,11 @@ namespace u16 { -template +template requires std::is_same_v, uint16_t> std::expected read(T& start, const T& end) { - if (start == end) return std::unexpected(u::ReadError::End); + if (start == end) + return std::unexpected(u::ReadError::End); uint16_t u = *start; if (u >= 0xd800 && u <= 0xdbff) { if (std::distance(start, end) < 2) { @@ -35,7 +36,7 @@ std::expected read(T& start, const T& end) { return u; } -template +template requires std::is_same_v, uint16_t> std::expected read_replace(T& start, const T& end, @@ -58,14 +59,16 @@ std::expected read_replace(T& start, return 0xfffd; } -template +template requires std::is_same_v, uint16_t> bool write(T& start, const T& end, uint32_t code) { if (code < 0x10000) { - if (start == end) return false; + if (start == end) + return false; *start = static_cast(code); } else { - if (std::distance(start, end) < 2) return false; + if (std::distance(start, end) < 2) + return false; code -= 0x10000; *start = static_cast(0xd800 + (code >> 10)); std::advance(start, 1); @@ -75,12 +78,14 @@ bool write(T& start, const T& end, uint32_t code) { return true; } -template +template requires std::is_same_v, uint16_t> bool skip(T& start, const T& end) { - if (start == end) return false; + if (start == end) + return false; if (*start >= 0xd800 && *start <= 0xdbff) { - if (std::distance(start, end) < 2) return false; + if (std::distance(start, end) < 2) + return false; std::advance(start, 2); return true; } -- cgit v1.3