This can't really be tested until C++20 move_iterator is completely implemented, but I'm working on that.
Depends on D117324.
Differential D117327
[libc++] Fix LWG3390: move_iterator now handles move-only iterators. • Quuxplusone on Jan 14 2022, 8:28 AM. Authored by
Details
This can't really be tested until C++20 move_iterator is completely implemented, but I'm working on that. Depends on D117324.
Diff Detail
Event TimelineComment Actions
Can't we add a simple test with a move_iterator constructed from a non-copyable iterator and ensure that works? What else is missing? This LGTM but I'd like to see tests for this, so I'll wait to see the child revisions I assume you're about to upload. Comment Actions @ldionne: I've uploaded my proposed test now, but as it turns out, it fails because move_it.base() returns by-value in C++17; actually pulling out the .base() of a move-only move_iterator requires the C++20 changes to make .base() return by-const-ref. I'd still prefer to land this as-is (without that test for now), but I guess I could also abandon this. My original rationale for opening this individually was that this is a (minor) change to the pre-C++20 behavior — it now moves instead of copying. I think everything else I'm doing affects our behavior only in C++20-and-later. (Okay, so technically this behavior is observable and therefore testable pre-C++20; I'd just have to make a local iterator type that is both copy-ctable and move-ctable, but its copy-ctor counts the number of times it's called, and verify that make_move_iterator(CountingItType()) never calls the copy-ctor. But that seems like overkill, IMVHO.) Comment Actions Ahh I see. Fine with this as-is without the test. I like to have a single commit for this LWG issue. My understanding is that you will then test that (and more) in D117656. |