johnmcfarlane / unformat

generates .clang-format file from example codebase
Apache License 2.0
315 stars 22 forks source link

compilation error with current {fmt} library version #27

Closed matgat closed 2 years ago

matgat commented 2 years ago

/usr/include/fmt/core.h:1757:7: error: static assertion failed: Cannot format an argument. To make type T formattable provide a formatter specialization: https://fmt.dev/latest/api.html#udt

Problem from both types boost::program_options::options_description and std::filesystem::path

johnmcfarlane commented 2 years ago

Hi there. That's not a lot of context to go on. Looks like maybe LLVM is having trouble parsing your code. Are you able to run clang-format on your code outside of unformat?

matgat commented 2 years ago

I think the newer versions of {fmt} added compile time checks and are a little strict about conversions. I solved the compilation error specifying on top of cl_config.cpp the proper formatters:

template<> struct fmt::formatter<std::filesystem::path>: formatter<std::string_view>
{
    template<typename FormatContext>
    auto format(const std::filesystem::path& path, FormatContext& ctx)
    {
        return formatter<std::string_view>::format(path.string(), ctx);
    }
};
template<> struct fmt::formatter<boost::program_options::options_description> : ostream_formatter {};