[libcxx-commits] [PATCH] D149826: [libc++][ranges] Implement the changes to vector from P1206 (`ranges::to`):

Asmaa via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Fri May 12 10:40:31 PDT 2023


asmok-g added a comment.

Before this patch, if a non-copy-constructible Iterator was passed to the vector constructor `vector<_Tp, _Allocator>::vector(_InputIterator __first, _InputIterator __last)` it compiled, but now it gives the error: `call to deleted constructor of 'Iterator'`.

smth like

  #include <iterator>
  #include <vector>
  
  const char* data = "abc";
  
  class Iterator : public std::iterator<std::input_iterator_tag, const char> {
   public:
    explicit Iterator(const char c) {}
    Iterator(const Iterator& other) = delete;
    Iterator& operator=(const Iterator& other) = delete;
    reference operator*() const { return data[0]; }
    void operator++() {}
    bool operator==(const Iterator& other) const { return true; }
    bool operator!=(const Iterator& other) const { return false; }
  };
  
  class Elem {
   public:
    Elem() = default;
    explicit Elem(const char ref) {}
  };
  
  int main(int argc, char** argv) {
    std::vector<Elem>(Iterator(data[0]), Iterator(data[1]));
  }


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149826



More information about the libcxx-commits mailing list