This is an archive of the discontinued LLVM Phabricator instance.

[libc++][test] Adds an cpp20_output_iterator.
ClosedPublic

Authored by Mordante on Mar 19 2022, 9:40 AM.

Details

Summary

This iterator is used to test code that only needs to satisfy the
output_iterator concept. Follow-up changes will use this iterator in
older language Standards.

Diff Detail

Event Timeline

Mordante created this revision.Mar 19 2022, 9:40 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 19 2022, 9:40 AM
Mordante requested review of this revision.Mar 19 2022, 9:40 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 19 2022, 9:40 AM
Herald added a reviewer: Restricted Project. · View Herald Transcript

@philnik if you start to work on the modifying ranges patches this new iterator will be useful for your tests.

libcxx/test/support/test_iterators.h
531

If D122074 is abandoned, there's no need for the pre C++20 support in this class.

Mordante planned changes to this revision.Mar 23 2022, 1:27 PM

Since D122074 is on hold (and might be abandoned) I want to remove all pre-c++20 features from this patch.
The patch is still useful for testing in the range based algorithms.

CaseyCarter added inline comments.
libcxx/test/support/test_iterators.h
541

This won't compile - *this is move-only,

It would be great if you remove the pre C++20 stuff. This would be nice to have for the ranges algorithm tests.

libcxx/test/support/test_iterators.h
540–544

The post-increment operator++ return void with the ranges stuff.

Mordante marked 2 inline comments as done.Mar 27 2022, 8:12 AM
Mordante added inline comments.
libcxx/test/support/test_iterators.h
540–544

Unfortunately that won't work since the concept requires *__it++ = _VSTD::forward<_Tp>(__t);, deferring a void won't work.

541

Good point, thanks!

Mordante updated this revision to Diff 418451.Mar 27 2022, 8:15 AM
Mordante marked 2 inline comments as done.

Rebase.
Address review comments.
Change to C++20 iterator only.

philnik accepted this revision as: philnik.Mar 27 2022, 4:16 PM

LGTM

libcxx/test/support/test_iterators.h
540–544

That's not very intuitive, but OK.

Gentle ping; I need this for ranges::fill.

var-const accepted this revision.Apr 4 2022, 11:19 AM
var-const added a subscriber: var-const.

Thanks for working on this!

This revision is now accepted and ready to land.Apr 4 2022, 11:19 AM
ldionne accepted this revision.Apr 4 2022, 2:49 PM

LGTM, but what's the difference between C++17's output iterator and C++20's?

LGTM, but what's the difference between C++17's output iterator and C++20's?

That an output iterator in C++20 doesn't need to be copyable.

This revision was automatically updated to reflect the committed changes.