Skip to content
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

Enable named arguments check in compile-time checks #2649

Merged
merged 1 commit into from
Dec 17, 2021

Conversation

alexezeder
Copy link
Contributor

Originated from #2640.

This check works only if all named arguments are UDL-based (statically_named).

Also, I'm not sure about format strings like "{} {named1}{named2}", they work in master, but by enabling this check I also applied the same logic for them as FMT_STRING and FMT_COMPILE have. So, those format string do not work.

It would be nice to add some compile-time error checks for this check in this PR, but it's probably should be done in #2648.

works only if all named arguments are UDL-based
Comment on lines +3051 to +3052
if constexpr (detail::count_named_args<Args...>() ==
detail::count_statically_named_args<Args...>()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't this effectively make fmt::arg unusable?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I understand, fmt::arg is handled the same way as before. Consider the following table with results of boolean expressions inside this if:

master PR
w/o named arguments true true
fmt::arg false false
_a false true
fmt::arg + _a false false

This way, nothing should change for fmt::arg. In contrast with format string with a mix of named and non-named arguments.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense.

@vitaut vitaut merged commit ef72b47 into fmtlib:master Dec 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants