Misc: Fix fmt errors

This commit is contained in:
JordanTheToaster 2023-11-28 10:19:22 +00:00 committed by Connor McLaughlin
parent 279c84f8e1
commit cefcd843fc
2 changed files with 25 additions and 0 deletions

View File

@ -114,6 +114,9 @@ if(GCC_VERSION VERSION_GREATER_EQUAL "9.0" AND GCC_VERSION VERSION_LESS "9.2")
This text being in a compile log in an open issue may cause it to be closed.")
endif()
# Prevent fmt from being built with exceptions, or being thrown at call sites.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DFMT_EXCEPTIONS=0")
add_subdirectory(3rdparty/fmt/fmt EXCLUDE_FROM_ALL)
add_subdirectory(3rdparty/rapidyaml/rapidyaml EXCLUDE_FROM_ALL)
add_subdirectory(3rdparty/lzma EXCLUDE_FROM_ALL)

View File

@ -321,3 +321,25 @@ __fi void SmallStringBase::fmt(fmt::format_string<T...> fmt, T&&... args)
clear();
fmt::vformat_to(std::back_inserter(*this), fmt, fmt::make_format_args(args...));
}
#define MAKE_FORMATTER(type) \
template <> \
struct fmt::formatter<type> \
{ \
template <typename ParseContext> \
constexpr auto parse(ParseContext& ctx) \
{ \
return ctx.begin(); \
} \
\
template <typename FormatContext> \
auto format(const type& str, FormatContext& ctx) \
{ \
return fmt::format_to(ctx.out(), "{}", str.view()); \
} \
};
MAKE_FORMATTER(TinyString);
MAKE_FORMATTER(SmallString);
#undef MAKE_FORMATTER