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

Add support for statically named arguments with FMT_STRING #2281

Merged
merged 1 commit into from
May 14, 2021

Conversation

alexezeder
Copy link
Contributor

Possible with this PR and a compiler with non-type template arguments support:

fmt::format(FMT_STRING("{foo}{bar}"), "bar"_a = "bar", "foo"_a = "foo");
"{foo}{bar}"_format("bar"_a = "bar", "foo"_a = "foo");

Still impossible:

fmt::format(FMT_STRING("{foo}{bar}"), fmt::arg("bar", "bar"), fmt::arg("foo", "foo"));
/fmt/include/fmt/core.h:2310:39: error: static assertion failed: use statically named arguments with compile-time format strings: fmt::arg("name", value) -> "name"_a = value

Copy link
Contributor

@vitaut vitaut left a comment

Choose a reason for hiding this comment

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

Thanks for the PR.

include/fmt/core.h Outdated Show resolved Hide resolved
include/fmt/core.h Outdated Show resolved Hide resolved
include/fmt/core.h Outdated Show resolved Hide resolved
@alexezeder alexezeder force-pushed the feature/FMT_STRING_with_named_args branch from bc9dfda to 26190ac Compare May 14, 2021 22:10
@alexezeder alexezeder force-pushed the feature/FMT_STRING_with_named_args branch from 26190ac to 3533f98 Compare May 14, 2021 23:04
@vitaut vitaut merged commit 54f22a3 into fmtlib:master May 14, 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