-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Restore constraint on map formatter #4326
Conversation
There was a problem hiding this 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! Looks good, just a minor question inline.
test/ranges-test.cc
Outdated
@@ -65,6 +67,9 @@ TEST(ranges_test, format_vector) { | |||
EXPECT_EQ(fmt::format("{:n}", vvc), "['a', 'b', 'c'], ['a', 'b', 'c']"); | |||
EXPECT_EQ(fmt::format("{:n:n}", vvc), "'a', 'b', 'c', 'a', 'b', 'c'"); | |||
EXPECT_EQ(fmt::format("{:n:n:}", vvc), "a, b, c, a, b, c"); | |||
|
|||
EXPECT_FALSE((fmt::is_formattable<unformattable>::value)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are extra parentheses needed here and in other places below?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. They were in the original (I moved this assertion up from the tuple one) so I just went with it, but I can remove the unnecessary ones.
@@ -83,6 +88,8 @@ TEST(ranges_test, format_map) { | |||
auto m = std::map<std::string, int>{{"one", 1}, {"two", 2}}; | |||
EXPECT_EQ(fmt::format("{}", m), "{\"one\": 1, \"two\": 2}"); | |||
EXPECT_EQ(fmt::format("{:n}", m), "\"one\": 1, \"two\": 2"); | |||
|
|||
EXPECT_FALSE((fmt::is_formattable<std::map<int, unformattable>>::value)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems that this is the only place that needs extra parentheses because of a comma.
Merged, thanks! |
So that it correctly reports as unformattable when the element is.
This was lost when the formatter was split out in 77bfd84