-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Fix is_formattable for tuple-like types. #2940
Conversation
d53bd19
to
0203853
Compare
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.
include/fmt/ranges.h
Outdated
static decltype(check2( | ||
index_sequence<I...>{}, | ||
integer_sequence< | ||
bool, (fmt::is_formattable<typename std::tuple_element<I, T>::type, |
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.
Is fmt::
needed here?
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, fixed.
test/ranges-test.cc
Outdated
enum class noformatenum{b}; | ||
struct noformatstruct{}; |
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.
Only one unformattable type is needed. Please reuse existing unformattable
struct (you might need to move it outside of conditional compilation block).
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.
Fixed.
Thank you! |
Fixes #2939.
Added a
is_tuple_formattable
helper value-trait to compute the formattability of the element-types of a tuple. Tried to make it look likeis_tuple_like
andis_tuple_like_
.Made the
xchar_test.format_map
conditional. This test formats a map, whose value-type isstd::pair<const std::wstring,int>
. Because tuple-likes now also take the formattability of element-types into account, and becauseis_formattable<std::wstring>
was false locally, this test no longer compiled. I was surprised that something that is not formattable could be formatted in the first place, and chose flight rather than fight.