From 86878a27113f311b2a7dba6ce905829e875bd8d8 Mon Sep 17 00:00:00 2001 From: Jan Niklas Hasse Date: Thu, 3 Oct 2024 10:20:11 +0200 Subject: [PATCH] Fix custom Vec2 formatting with libc++ --- src/jngl/Vec2.hpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/jngl/Vec2.hpp b/src/jngl/Vec2.hpp index abbd2714..04a06fe2 100644 --- a/src/jngl/Vec2.hpp +++ b/src/jngl/Vec2.hpp @@ -65,9 +65,12 @@ std::ostream& operator<<(std::ostream&, const Vec2&); } // namespace jngl #if __has_include() && (!defined(_LIBCPP_VERSION) || _LIBCPP_VERSION >= 170000) -template <> struct std::formatter : std::formatter { - auto format(jngl::Vec2 v, format_context& ctx) const { - return formatter::format(std::format("[x={}, y={}]", v.x, v.y), ctx); +template <> struct std::formatter { + constexpr auto parse(std::format_parse_context& ctx) { + return ctx.begin(); + } + auto format(const jngl::Vec2& v, auto& ctx) const { + return std::format_to(ctx.out(), "[x={}, y={}]", v.x, v.y); } }; #endif