From 4fac1b80089285d35023b4f63d4436f2c30c5ef8 Mon Sep 17 00:00:00 2001 From: lukasx999 <116069013+lukasx999@users.noreply.github.com> Date: Mon, 21 Jul 2025 01:45:29 +0200 Subject: [PATCH] added c++20 formatters --- src/raylib.h | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/src/raylib.h b/src/raylib.h index 0ea0df316..b112e6cca 100644 --- a/src/raylib.h +++ b/src/raylib.h @@ -1713,4 +1713,54 @@ RLAPI void DetachAudioMixedProcessor(AudioCallback processor); // Detach audio s } #endif +#if __cplusplus >= 202002L && !defined(RAYLIB_DISABLE_CPP_FORMATTERS) + +// Optional C++20 formatters +//------------------------------------------------------------------------------- + +#include + +template <> +struct std::formatter : std::formatter { + auto format(Vector4 v, std::format_context& ctx) const { + auto fmt = std::format("{{{}, {}, {}, {}}}", v.x, v.y, v.z, v.w); + return std::formatter::format(fmt, ctx); + } +}; + +template <> +struct std::formatter : std::formatter { + auto format(Vector3 v, std::format_context& ctx) const { + auto fmt = std::format("{{{}, {}, {}}}", v.x, v.y, v.z); + return std::formatter::format(fmt, ctx); + } +}; + +template <> +struct std::formatter : std::formatter { + auto format(Vector2 v, std::format_context& ctx) const { + auto fmt = std::format("{{{}, {}}}", v.x, v.y); + return std::formatter::format(fmt, ctx); + } +}; + +template <> +struct std::formatter : std::formatter { + auto format(Rectangle rec, std::format_context& ctx) const { + auto fmt = std::format("{{{}, {}, {}, {}}}", rec.x, rec.y, rec.width, rec.height); + return std::formatter::format(fmt, ctx); + } +}; + +template <> +struct std::formatter : std::formatter { + auto format(Color color, std::format_context& ctx) const { + auto fmt = std::format("{{{}, {}, {}}}", color.r, color.g, color.b); + return std::formatter::format(fmt, ctx); + } +}; + +//------------------------------------------------------------------------------- +#endif // C++20 formatters + #endif // RAYLIB_H