[libcxx-commits] [PATCH] D99854: [libcxx] adds `cpp17-.*iterator` concepts for iterator_traits

Casey Carter via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Thu Apr 15 13:03:37 PDT 2021


CaseyCarter added inline comments.


================
Comment at: libcxx/include/iterator:659
+template<class _Ip>
+concept __legacy_iterator =
+  requires(_Ip __i) {
----------------
ldionne wrote:
> @CaseyCarter  Is it intended that the exposition-only concepts defined in http://eel.is/c++draft/iterator.traits#2 are not a literal translation of tables like http://eel.is/c++draft/iterator.cpp17#tab:iterator?
> 
> For example, the exposition-only concept `cpp17-iterator` adds the requirement `{ *i++ } -> can-reference`, whereas the `Cpp17Iterator` concept does not contain that requirement.
> 
> There are similar differences in the other iterator concepts too, like `operator->` being in the table but not in the exposition-only concept.
> @CaseyCarter  Is it intended that the exposition-only concepts defined in http://eel.is/c++draft/iterator.traits#2 are not a literal translation of tables like http://eel.is/c++draft/iterator.cpp17#tab:iterator?

Yes. It is intended.
 
> For example, the exposition-only concept `cpp17-iterator` adds the requirement `{ *i++ } -> can-reference`, whereas the `Cpp17Iterator` concept does not contain that requirement.

True, but both Cpp17InputIterator and Cpp17OutputIterator effectively require something stronger that refines this requirement. I _think_ this was just a convenient shortcut,

> There are similar differences in the other iterator concepts too, like `operator->` being in the table but not in the exposition-only concept.

There's no way to express the `->` requirement with concepts, since we don't generally know the member names (if any) of the value type. This is also why we dropped `->` from the iterator concepts: generic code can't use `->` because it doesn't know what it can put on the right-hand side.



Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D99854/new/

https://reviews.llvm.org/D99854



More information about the libcxx-commits mailing list