From faf77949e19dc0d01f75bf8abb783eda70328048 Mon Sep 17 00:00:00 2001 From: Yuqian Yang Date: Fri, 17 Oct 2025 10:01:30 +0800 Subject: Platform base no String. --- include/cru/base/StringUtil.h | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'include/cru/base/StringUtil.h') diff --git a/include/cru/base/StringUtil.h b/include/cru/base/StringUtil.h index d79c0c23..0ce3802f 100644 --- a/include/cru/base/StringUtil.h +++ b/include/cru/base/StringUtil.h @@ -3,8 +3,8 @@ #include "Bitmask.h" #include +#include #include -#include #include #include #include @@ -30,6 +30,25 @@ struct SplitOptions { std::vector Split(std::string_view str, std::string_view sep, SplitOption options = {}); + +template +struct ImplementFormatterByToString { + template + constexpr ParseContext::iterator parse(ParseContext& ctx) const { + auto iter = ctx.begin(); + if (*iter != '}') { + throw std::format_error( + "ImplementFormatterByToString does not accept format args."); + } + return iter; + } + + template + FmtContext::iterator format(const T& object, FmtContext& ctx) const { + return std::ranges::copy(object.ToString(), ctx.out()).out; + } +}; + } // namespace string using CodePoint = std::int32_t; -- cgit v1.2.3