[libcxx-commits] [PATCH] D117400: [libc++] [test] Refactor iterators.common/ctor.pass.cpp
Casey Carter via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Jan 17 11:37:02 PST 2022
CaseyCarter added inline comments.
================
Comment at: libcxx/test/std/iterators/predef.iterators/iterators.common/ctor.pass.cpp:34
+ static_assert( std::is_default_constructible_v<std::common_iterator<int*, sentinel_wrapper<int*>>>);
+ static_assert(!std::is_default_constructible_v<std::common_iterator<cpp17_input_iterator<int*>, sentinel_wrapper<cpp17_input_iterator<int*>>>>);
----------------
Quuxplusone wrote:
> ldionne wrote:
> > See, now you understand why I fixed `cpp17_input_iterator` to *not* be default constructible! 😄
> I'll admit, it was convenient. ;)
> I think what I wanted here was one default-constructible input iterator and one non-; which could have been `cpp17_input_iterator` and `cpp20_input_iterator`; except that `cpp20_input_iterator` is //also// not copyable, and I forget but I think that might disqualify it from use with `common_iterator`.
> I think what I wanted here was one default-constructible input iterator and one non-; which could have been `cpp17_input_iterator` and `cpp20_input_iterator`; except that `cpp20_input_iterator` is //also// not copyable, and I forget but I think that might disqualify it from use with `common_iterator`.
That's correct: `common_iterator<I, S>` requires `copyable<I>` - it was the most expedient fix after relaxing the iterator requirements to allow move-only single-pass iterators. I believe it _could_ support move-only iterators by storing a `variant<shared_ptr<I>, S>`, but someone would need to flesh out and implement that design and write a paper.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D117400/new/
https://reviews.llvm.org/D117400
More information about the libcxx-commits
mailing list