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

Fix is_formattable for tuple-like types. #2940

Merged
merged 5 commits into from
Jun 19, 2022

Conversation

jehelset
Copy link
Contributor

@jehelset jehelset commented Jun 18, 2022

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 like is_tuple_like and is_tuple_like_.

Made the xchar_test.format_map conditional. This test formats a map, whose value-type is std::pair<const std::wstring,int>. Because tuple-likes now also take the formattability of element-types into account, and because is_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.

@jehelset jehelset force-pushed the jehelset/is-tuple-formattable branch from d53bd19 to 0203853 Compare June 18, 2022 15:02
test/xchar-test.cc Outdated Show resolved Hide resolved
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.

static decltype(check2(
index_sequence<I...>{},
integer_sequence<
bool, (fmt::is_formattable<typename std::tuple_element<I, T>::type,
Copy link
Contributor

Choose a reason for hiding this comment

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

Is fmt:: needed here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, fixed.

Comment on lines 94 to 95
enum class noformatenum{b};
struct noformatstruct{};
Copy link
Contributor

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).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

@vitaut vitaut merged commit 5682338 into fmtlib:master Jun 19, 2022
@vitaut
Copy link
Contributor

vitaut commented Jun 19, 2022

Thank you!

@jehelset jehelset deleted the jehelset/is-tuple-formattable branch June 19, 2022 15:29
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.

tuple-formatter doesn't check that the tuple-elements are formattable.
4 participants