[libcxx-commits] [PATCH] D113695: [libcxx] Implement three-way comparison for std::reverse_iterator

Mikhail Maltsev via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Mon Nov 22 05:02:41 PST 2021


miyuki marked 2 inline comments as done.
miyuki added inline comments.


================
Comment at: libcxx/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.cmp/three-way.pass.cpp:46
+
+struct Iter : ConstIter {
+    using iterator_category = std::bidirectional_iterator_tag;
----------------
Quuxplusone wrote:
> https://quuxplusone.github.io/blog/2021/07/14/an-iterator-is-not-a-const-iterator/
> All you're trying to do here is create a conversion
> ```
> ConstIter(Iter it): m_value(it.m_value) {}
> ```
> right? Just write that one line. :)
> 
> Note that if these were real iterators, in C++20, inheritance would //totally// not work, because you'd have signatures like `ConstIter& Iter::operator++()` which wouldn't satisfy the iterator concepts. Inheritance and value-semantic types //really// do not mix.
> https://quuxplusone.github.io/blog/2021/07/14/an-iterator-is-not-a-const-iterator/
> std::vector<int>::iterator b;
> std::vector<int>::const_iterator& rb = b;  // 1

Thanks, now I finally got it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113695



More information about the libcxx-commits mailing list