fmtlib / fmt

A modern formatting library
https://fmt.dev
Other
20.74k stars 2.49k forks source link

Example for Argument lists does not perform compile time checks #3305

Closed remyjette closed 1 year ago

remyjette commented 1 year ago

In https://fmt.dev/latest/api.html#argument-lists the docs state "You can create your own formatting function with compile-time checks and small binary footprint" and provide an example.

I tried putting that example into Compiler Explorer, and thus far am unable to get it to perform checks at compile time. I wondered if it was because the function did not have visibility into the arguments during compile time checks, but even an invalid formatting string with an unmatched { is not caught at compile time, only at runtime with a fmt::v9::format_error.

Am I doing something wrong, or does that example not actually support compile-time checks despite the docs saying it does? Or are there some compile time checks it can do but not all, and I just didn't find any of those?

https://godbolt.org/z/3ox8n8eP4

mwinterb commented 1 year ago

The documentation wasn't fully updated for 9.0.

The example from docs from the current master works fine in 9.0: https://fmt.dev/dev/api.html#argument-lists

On Tue, Feb 14, 2023, 16:15 Remy Jette @.***> wrote:

In https://fmt.dev/latest/api.html#argument-lists the docs state "You can create your own formatting function with compile-time checks and small binary footprint" and provide an example.

I tried putting that example into Compiler Explorer, and thus far am unable to get it to perform checks at compile time. I wondered if it was because the function did not have visibility into the arguments during compile time checks, but even an invalid formatting string with an unmatched { is not caught at compile time, only at runtime with a fmt::v9::format_error.

Am I doing something wrong, or does that example not actually support compile-time checks despite the docs saying it does? Or are there some compile time checks it can do but not all, and I just didn't find any of those?

https://godbolt.org/z/3ox8n8eP4

— Reply to this email directly, view it on GitHub https://github.com/fmtlib/fmt/issues/3305, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAIID34UB5LE7LNMDMZP2X3WXQNZTANCNFSM6AAAAAAU4GL5WM . You are receiving this because you are subscribed to this thread.Message ID: @.***>

remyjette commented 1 year ago

Ah, thank you! Yes that works perfectly.