diff options
author | Yuqian Yang <crupest@crupest.life> | 2025-09-07 19:51:27 +0800 |
---|---|---|
committer | Yuqian Yang <crupest@crupest.life> | 2025-09-07 19:51:27 +0800 |
commit | d36ed6c52f679ad0f9a0e89a4e1d09b763f063b8 (patch) | |
tree | 6f19180c95de0dc627848835b2497e93ce34b886 /include/cru | |
parent | 6e04e90a803e9f0fad296d993f26eab076753449 (diff) | |
download | cru-d36ed6c52f679ad0f9a0e89a4e1d09b763f063b8.tar.gz cru-d36ed6c52f679ad0f9a0e89a4e1d09b763f063b8.tar.bz2 cru-d36ed6c52f679ad0f9a0e89a4e1d09b763f063b8.zip |
Move ImplementFormatterByToUtf8String.
Diffstat (limited to 'include/cru')
-rw-r--r-- | include/cru/base/Format.h | 13 | ||||
-rw-r--r-- | include/cru/platform/GraphicsBase.h | 18 |
2 files changed, 16 insertions, 15 deletions
diff --git a/include/cru/base/Format.h b/include/cru/base/Format.h index d5c5ed99..83fda3f1 100644 --- a/include/cru/base/Format.h +++ b/include/cru/base/Format.h @@ -151,4 +151,17 @@ template <typename... T> String String::Format(T&&... args) const { return cru::Format(*this, std::forward<T>(args)...); } + +template <typename T> +struct ImplementFormatterByToUtf8String { + template <class ParseContext> + constexpr ParseContext::iterator parse(ParseContext& ctx) const { + return ctx.end(); + } + + template <class FmtContext> + FmtContext::iterator format(const T& object, FmtContext& ctx) const { + return std::ranges::copy(ToUtf8String(object), ctx.out()).out; + } +}; } // namespace cru diff --git a/include/cru/platform/GraphicsBase.h b/include/cru/platform/GraphicsBase.h index fb8d6bdd..5c4435ea 100644 --- a/include/cru/platform/GraphicsBase.h +++ b/include/cru/platform/GraphicsBase.h @@ -1,6 +1,7 @@ #pragma once #include "Base.h" +#include "cru/base/Format.h" #include "cru/base/Range.h" #include "cru/base/String.h" @@ -295,23 +296,10 @@ constexpr bool operator!=(const Ellipse& left, const Ellipse& right) { using TextRange = Range; } // namespace cru::platform -template <typename T> -struct ImplementFormatterByToUtf8String { - template <class ParseContext> - constexpr ParseContext::iterator parse(ParseContext& ctx) const { - return ctx.end(); - } - - template <class FmtContext> - FmtContext::iterator format(const T& object, FmtContext& ctx) const { - return std::ranges::copy(ToUtf8String(object), ctx.out()).out; - } -}; - template <> struct std::formatter<cru::platform::Point, char> - : ImplementFormatterByToUtf8String<cru::platform::Point> {}; + : cru::ImplementFormatterByToUtf8String<cru::platform::Point> {}; template <> struct std::formatter<cru::platform::Size, char> - : ImplementFormatterByToUtf8String<cru::platform::Size> {}; + : cru::ImplementFormatterByToUtf8String<cru::platform::Size> {}; |