From d36ed6c52f679ad0f9a0e89a4e1d09b763f063b8 Mon Sep 17 00:00:00 2001 From: Yuqian Yang Date: Sun, 7 Sep 2025 19:51:27 +0800 Subject: Move ImplementFormatterByToUtf8String. --- include/cru/base/Format.h | 13 +++++++++++++ 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 String String::Format(T&&... args) const { return cru::Format(*this, std::forward(args)...); } + +template +struct ImplementFormatterByToUtf8String { + template + constexpr ParseContext::iterator parse(ParseContext& ctx) const { + return ctx.end(); + } + + template + 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 -struct ImplementFormatterByToUtf8String { - template - constexpr ParseContext::iterator parse(ParseContext& ctx) const { - return ctx.end(); - } - - template - FmtContext::iterator format(const T& object, FmtContext& ctx) const { - return std::ranges::copy(ToUtf8String(object), ctx.out()).out; - } -}; - template <> struct std::formatter - : ImplementFormatterByToUtf8String {}; + : cru::ImplementFormatterByToUtf8String {}; template <> struct std::formatter - : ImplementFormatterByToUtf8String {}; + : cru::ImplementFormatterByToUtf8String {}; -- cgit v1.2.3