为 kqm::string 和 kqm::string_view 添加格式化支持

This commit is contained in:
keqingmoe 2025-03-14 12:33:35 +08:00
parent 913dc6548a
commit f47d5dd8f3
2 changed files with 18 additions and 0 deletions

View File

@ -700,3 +700,12 @@ using string = basic_string<std::pmr::polymorphic_allocator<std::byte>>;
}
}
export template <typename Allocator>
struct std::formatter<kqm::basic_string<Allocator>, char> : std::formatter<kqm::string_view, char>
{
auto format(const kqm::basic_string<Allocator>& s, auto&& ctx) const
{
return std::formatter<kqm::string_view, char>::format(s.all(), ctx);
}
};

View File

@ -213,3 +213,12 @@ public:
};
}
export template <>
struct std::formatter<kqm::string_view, char> : std::formatter<std::string_view, char>
{
auto format(kqm::string_view s, auto&& ctx) const
{
return std::formatter<std::string_view, char>::format(s.to_std_string_view(), ctx);
}
};