Skip to content

Json and fmt::lib's format_arg() #964

Description

@AlexandreBossard

Bug Report

jsonbug.zip

I use the glorious fmt::lib for my project. Since i got bored of typing code
like fmt::print("my json {}", jsonvar.dump(2));, i set myself to use the fmt customization point for user-defined type.

Normally, fmtlib trigger static_assert when unrecognized type are passed as arguments, asking you to defined format_arg() or an ostream<< overload.

Not with nhlomann::json. I get some horrible error messages with gcc (7.2.0) with an ambiguous call to a constructor of some fmtlib internals.

By digging fmt code, i found a macro which disabled implicit int conversion. Shooting in the dark, copy paste the macro, and passing nhlomann::json to it. Fixed!

I am not sure if this is a the fmtlib or json fault (both?). But looking for related issues in both project, i found this one #958, which kind of help me.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    solution: wontfixthe issue will not be fixed (either it is impossible or deemed out of scope)state: help neededthe issue needs help to proceedstate: please discussplease discuss the issue or vote for your favorite option

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions