-
Notifications
You must be signed in to change notification settings - Fork 1.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
<format>: Implement P2418R2 support for std::generator
-like types
#2323
<format>: Implement P2418R2 support for std::generator
-like types
#2323
Conversation
std::generator
-like types
tests/std/tests/P0645R10_text_formatting_custom_formatting/test.cpp
Outdated
Show resolved
Hide resolved
tests/std/tests/P0645R10_text_formatting_custom_formatting/test.cpp
Outdated
Show resolved
Hide resolved
…ing that it not const formattable.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
stl/inc/format
Outdated
_NODISCARD auto make_format_args(const _Args&... _Vals) { | ||
return _Format_arg_store<_Context, _Args...>{_Vals...}; | ||
_NODISCARD auto make_format_args(_Args&&... _Vals) { | ||
return _Format_arg_store<_Context, _Args...>{_STD forward<_Args>(_Vals)...}; |
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.
Why are we forwarding when the Working Draft doesn't show forwarding? (Also on 2966.) If we don't forward here, the _Format_arg_store
constructor can/should be changed to take only lvalues.
Have you submitted an LWG issue to fix the preconditions on these functions to strip cvref-quals from the T
i?
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.
I'm forwarding because libfmt forwards here, I think you're right though and they forward everywhere but then specifically undo what the forwarding would have done when make_arg
binds them all to the fmt equivalent to const _Storage_type<remove_cvref_t<T>>&
Have you submitted an LWG issue to fix the preconditions on these functions to strip cvref-quals from the Ti?
no, but Tim Song did.
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.
wait is this a separate issue from LWG-3631?
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.
Yes it is - [format.arg.store]/2. We can do this as a followup - it doesn't need to block merging.
tests/std/tests/P0645R10_text_formatting_custom_formatting/test.cpp
Outdated
Show resolved
Hide resolved
I pushed a conflict-free merge with |
I'm mirroring this to the MSVC-internal repo - please notify me if any further changes are pushed. |
Thanks for implementing the last C++20 DR! 🎉 😻 ✅ |
Implements P2418R2 which prepares format to be able to format std::generators, by allowing "format" functions that take their parameters by non-const reference. This DR is somewhat high risk because it modifies the argument type mapping machinery.
_Storage_type
to useremove_cvref_t<T>
instead ofT
because that's what the "other end" (the un-erase from handle) uses now. I don't think this has actual effect on the mapping, but could change the selected formatter specialization for custom types. Tim Song indicated on the reflectors that the lack ofremove_cvref_t<T>
in [format.arg]/5 is probably a defect._Has_formatter
and the new_Has_const_formatter
concepts have been moved up since they are now needed in the constructor forbasic_format_arg::handle
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p2418r2.html
Fixes #2239.