New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compile time checking of format string? #295

Closed
paulsapps opened this Issue Mar 17, 2016 · 3 comments

Comments

Projects
None yet
3 participants
@paulsapps

paulsapps commented Mar 17, 2016

Would it be possible to add this feature using constexpr compile time format string checking? For example:

fmt::format("{} {}", "blah");

Would result in compile time instead of run time error..

@nabijaczleweli

This comment has been minimized.

Show comment
Hide comment
@nabijaczleweli

nabijaczleweli Mar 17, 2016

No, TTBOMK, because one can't pass string literals as template arguments, so compile-time string inspection is well-nigh impossible.

nabijaczleweli commented Mar 17, 2016

No, TTBOMK, because one can't pass string literals as template arguments, so compile-time string inspection is well-nigh impossible.

@vitaut

This comment has been minimized.

Show comment
Hide comment
@vitaut

vitaut Mar 17, 2016

Contributor

Unfortunately it is not possible (at least with a usable API) at the moment because of the difficulties of handling string literals that @nabijaczleweli mentioned.

However, you can get compile-time checking of printf-style format strings (but not Python-like format strings) as described in #62 (comment).

Contributor

vitaut commented Mar 17, 2016

Unfortunately it is not possible (at least with a usable API) at the moment because of the difficulties of handling string literals that @nabijaczleweli mentioned.

However, you can get compile-time checking of printf-style format strings (but not Python-like format strings) as described in #62 (comment).

@vitaut vitaut closed this Mar 17, 2016

@vitaut

This comment has been minimized.

Show comment
Hide comment
@vitaut

vitaut Nov 6, 2017

Contributor

Compile-time format string checks are now available: http://zverovich.net/2017/11/05/compile-time-format-strings.html

Contributor

vitaut commented Nov 6, 2017

Compile-time format string checks are now available: http://zverovich.net/2017/11/05/compile-time-format-strings.html

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