From 27b163f4db78822656456f44d5e20aaac42fa0e7 Mon Sep 17 00:00:00 2001 From: Patrick Wuttke Date: Sun, 26 Nov 2023 15:13:06 +0100 Subject: [PATCH] Added libfmt support for Name. --- source/mijin/types/name.hpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/source/mijin/types/name.hpp b/source/mijin/types/name.hpp index 74601b0..2bae605 100644 --- a/source/mijin/types/name.hpp +++ b/source/mijin/types/name.hpp @@ -6,6 +6,9 @@ #include #include +#if __has_include() +# include +#endif namespace mijin { @@ -49,15 +52,24 @@ public: } // namespace mijin -namespace std -{ template<> -struct hash : hash +struct std::hash : hash { std::size_t operator()(mijin::Name name) const noexcept { return hash::operator()(name.getID()); } }; -} + +#if __has_include() +template<> +struct fmt::formatter : fmt::formatter +{ + template + auto format(mijin::Name name, TContext& ctx) const -> decltype(ctx.out()) + { + return fmt::formatter::format(name.stringView(), ctx); + } +}; +#endif // __has_include() #endif // !defined(MIJIN_TYPES_NAME_HPP_INCLUDED)