From e1a1164136e3d3d1999b4b577f95cb836186022c Mon Sep 17 00:00:00 2001 From: Orange Date: Thu, 18 Sep 2025 19:06:56 +0300 Subject: [PATCH] fixed warning --- include/omath/angle.hpp | 38 ++++++++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/include/omath/angle.hpp b/include/omath/angle.hpp index 7f589a5..1f9d820 100644 --- a/include/omath/angle.hpp +++ b/include/omath/angle.hpp @@ -151,21 +151,39 @@ namespace omath }; } // namespace omath -template -struct std::formatter, CharT> +template +struct std::formatter, char> // NOLINT(*-dcl58-cpp) { using AngleT = omath::Angle; - [[nodiscard]] - static constexpr auto parse(std::basic_format_parse_context& ctx) - -> std::basic_format_parse_context::iterator + + static constexpr auto parse(std::format_parse_context& ctx) { return ctx.begin(); } + template - auto format(const AngleT& deg, FormatContext& ctx) const + auto format(const AngleT& a, FormatContext& ctx) const { - if constexpr (std::is_same_v) - return std::format_to(ctx.out(), "{}deg", deg.as_degrees()); - return std::format_to(ctx.out(), L"{}deg", deg.as_degrees()); + static_assert(std::is_same_v); + return std::format_to(ctx.out(), "{}deg", a.as_degrees()); } -}; \ No newline at end of file +}; + +// wchar_t formatter +template +struct std::formatter, wchar_t> // NOLINT(*-dcl58-cpp) +{ + using AngleT = omath::Angle; + + static constexpr auto parse(std::wformat_parse_context& ctx) + { + return ctx.begin(); + } + + template + auto format(const AngleT& a, FormatContext& ctx) const + { + static_assert(std::is_same_v); + return std::format_to(ctx.out(), L"{}deg", a.as_degrees()); + } +};