I have a wrapper on top of spdlog, and after upgrading the spdlog and fmt versions, I have a bunch of errors because some of my types doesn’t provide a formatter. Instead of adding fmt::streamed
where I call spdlog with my types, I am trying to add a template function that calls fmt::streamed
if there isnt a formatter, and just returns the original value otherwise.
template <typename Arg>
int streamedIfNeeded(Arg &&arg) {
if constexpr(std::is_invocable_v<decltype(fmt::format<fmt::format_string<Arg>, Arg&&>), decltype("{}"), Arg>) {
return arg;
} else {
return fmt::streamed(arg);
}
}
However, this is not working correctly. As shown in https://godbolt.org/z/dddsqv9x6 , it is always going through the false branch.
How should I fix this template so it works as expected?