// SPDX-FileCopyrightText: Copyright 2014 Citra Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later #pragma once #include #include // Adapted from https://github.com/fmtlib/fmt/issues/2704 // a generic formatter for enum classes #if FMT_VERSION >= 80100 template struct fmt::formatter, char>> : formatter> { template auto format(const T& value, FormatContext& ctx) -> decltype(ctx.out()) { return fmt::formatter>::format( static_cast>(value), ctx); } }; #endif namespace fmt { template struct UTF { T data; explicit UTF(const std::u8string_view view) { data = view.empty() ? T{} : T{(const char*)&view.front(), (const char*)&view.back() + 1}; } explicit UTF(const std::u8string& str) : UTF(std::u8string_view{str}) {} }; } // namespace fmt template <> struct fmt::formatter, char> : formatter { template auto format(const UTF& wrapper, FormatContext& ctx) const { return formatter::format(wrapper.data, ctx); } };