[libcxx-commits] [PATCH] D139235: Reapply "[libc++][ranges]Refactor `copy{, _backward}` and `move{, _backward}`"

Jordan Rupprecht via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Wed Jan 25 11:35:08 PST 2023


rupprecht added a comment.

Not a breakage report, but just a comment in case it wasn't expected/intended: it looks like this increases the conformance requirement for custom iterators passed to `std::copy` and friends. From a couple tests, it seems like gcc/libstdc++ already has stricter requirements than libc++, so the conformance requirement is being matched between libc++ and libstdc++ now. As an example:

  struct MyIterator {
      using iterator_category = std::forward_iterator_tag;
      using value_type = float;
      // These two lines are now also needed
      // using pointer = float*;
      // using reference = const float&;
      using difference_type = std::ptrdiff_t;
      value_type operator*();
      MyIterator& operator++();
      friend bool operator==(const MyIterator&, const MyIterator&);
      friend bool operator!=(const MyIterator&, const MyIterator&);
  };
  
  void func() {
      std::vector<float> dest;
      std::copy(MyIterator(), MyIterator(), std::back_inserter(dest));
  }

https://godbolt.org/z/jTdbT4xcP

It seems pretty clear the change here is correct, this is just an FYI of the impact & in case anyone else bumps into this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139235



More information about the libcxx-commits mailing list