formatter.h
1 // Copyright 2022 Citra Emulator Project 2 // Licensed under GPLv2 or any later version 3 // Refer to the license.txt file included. 4 5 #pragma once 6 7 #include <type_traits> 8 #include <fmt/format.h> 9 10 // adapted from https://github.com/fmtlib/fmt/issues/2704 11 // a generic formatter for enum classes 12 #if FMT_VERSION >= 80100 13 template <typename T> 14 struct fmt::formatter<T, std::enable_if_t<std::is_enum_v<T>, char>> 15 : formatter<std::underlying_type_t<T>> { 16 template <typename FormatContext> 17 auto format(const T& value, FormatContext& ctx) -> decltype(ctx.out()) { 18 return fmt::formatter<std::underlying_type_t<T>>::format( 19 static_cast<std::underlying_type_t<T>>(value), ctx); 20 } 21 }; 22 #endif