-
Notifications
You must be signed in to change notification settings - Fork 1.6k
<format>: Allow move-only output iterators #1795
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>: Allow move-only output iterators #1795
Conversation
Had to "move" them, eh? Good one! |
7bae485 to
5e63376
Compare
|
Squashed and rebased. Double checked that I didn't undo any |
|
|
||
| iterator out() { | ||
| return _OutputIt; | ||
| return _STD move(_OutputIt); |
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.
this makes me spooked! in particular because basic_format_context and basic_format_parse_context are to be used in user supplied custom formatters
| template <class _Ty> | ||
| _OutputIt operator()(_Ty _Val) { | ||
| return _Write<_CharT>(_Out, _Val); | ||
| return _Write<_CharT>(_STD move(_Out), _Val); |
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.
This means _Default_arg_formatter op()s can also be called only once, like the basic_format_context .out() member function.
| basic_format_parse_context<_CharT> _Parse_ctx({}); | ||
| basic_format_context<_OutputIt, _CharT> _Format_ctx(_Out, _Args, _Loc); | ||
| basic_format_context<_OutputIt, _CharT> _Format_ctx(_STD move(_Out), _Args, _Loc); | ||
| _Handle.format(_Parse_ctx, _Format_ctx); |
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.
This copy may be problematic.
|
There is an outstanding issue with custom formatting. It's not a result of this PR, but running the tests without |
Now we move around the iterator we get instead of copying it. I had to move a few functions from their home in algorithm and xmemory into xutility. I hope I got the comments/guards correct, but please double check those. The testing is done by making sure we don't use-after-move a custom iterator and that all the printing functions are instantiated.
1317e95 to
17d3030
Compare
|
Rebased, double check the function moves as those were re-done (xutilty, xmemory, algorithm). |
miscco
left a comment
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 am not 100% up to date with fmt but the changes look good for me
Now we move around the iterator we get instead of copying it. I had to
move a few functions from their home in algorithm and xmemory into
xutility. I hope I got the comments/guards correct, but please double
check those.
The testing is done by making sure we don't use-after-move a custom
iterator and that all the printing functions are instantiated.