Lines Matching +full:- +full:it
1 //===----------------------------------------------------------------------===//
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
28 template <class It>
31 It it_;
38 typedef typename std::iterator_traits<It>::difference_type difference_type;
39 typedef It pointer;
40 typedef typename std::iterator_traits<It>::reference reference;
42 TEST_CONSTEXPR explicit cpp17_output_iterator(It it) : it_(std::move(it)) {}
58 friend TEST_CONSTEXPR It base(const cpp17_output_iterator& i) { return i.it_; }
64 template <class It>
65 cpp17_output_iterator(It) -> cpp17_output_iterator<It>;
74 template <class It, class ItTraits = It>
78 It it_;
86 typedef It pointer;
89 TEST_CONSTEXPR explicit cpp17_input_iterator(It it) : it_(it) {}
108 friend TEST_CONSTEXPR It base(const cpp17_input_iterator& i) { return i.it_; }
114 template <class It>
115 cpp17_input_iterator(It) -> cpp17_input_iterator<It>;
122 template <class It>
125 It it_;
131 typedef typename std::iterator_traits<It>::value_type value_type;
132 typedef typename std::iterator_traits<It>::difference_type difference_type;
133 typedef It pointer;
134 typedef typename std::iterator_traits<It>::reference reference;
137 TEST_CONSTEXPR explicit forward_iterator(It it) : it_(it) {}
156 friend TEST_CONSTEXPR It base(const forward_iterator& i) { return i.it_; }
162 template <class It>
163 forward_iterator(It) -> forward_iterator<It>;
166 template <class It>
169 It it_;
175 typedef typename std::iterator_traits<It>::value_type value_type;
176 typedef typename std::iterator_traits<It>::difference_type difference_type;
177 typedef It pointer;
178 typedef typename std::iterator_traits<It>::reference reference;
181 TEST_CONSTEXPR explicit bidirectional_iterator(It it) : it_(it) {}
195 TEST_CONSTEXPR_CXX14 bidirectional_iterator& operator--() {--it_; return *this;}
197 TEST_CONSTEXPR_CXX14 bidirectional_iterator operator--(int) {return bidirectional_iterator(it_--);}
202 friend TEST_CONSTEXPR It base(const bidirectional_iterator& i) { return i.it_; }
208 template <class It>
209 bidirectional_iterator(It) -> bidirectional_iterator<It>;
212 template <class It>
215 It it_;
221 typedef typename std::iterator_traits<It>::value_type value_type;
222 typedef typename std::iterator_traits<It>::difference_type difference_type;
223 typedef It pointer;
224 typedef typename std::iterator_traits<It>::reference reference;
227 TEST_CONSTEXPR explicit random_access_iterator(It it) : it_(it) {}
242 TEST_CONSTEXPR_CXX14 random_access_iterator& operator--() {--it_; return *this;}
244 TEST_CONSTEXPR_CXX14 random_access_iterator operator--(int) {return random_access_iterator(it_--);}
247 TEST_CONSTEXPR_CXX14 random_access_iterator& operator-=(difference_type n) {it_ -= n; return *this;}
250 friend TEST_CONSTEXPR_CXX14 random_access_iterator operator-(random_access_iterator x, difference_type n) {x -= n; return x;}
251 friend TEST_CONSTEXPR difference_type operator-(random_access_iterator x, random_access_iterator y) {return x.it_ - y.it_;}
260 friend TEST_CONSTEXPR It base(const random_access_iterator& i) { return i.it_; }
266 template <class It>
267 random_access_iterator(It) -> random_access_iterator<It>;
272 template <std::random_access_iterator It>
274 It it_;
283 using value_type = typename std::iterator_traits<It>::value_type;
284 using difference_type = typename std::iterator_traits<It>::difference_type;
287 constexpr explicit cpp20_random_access_iterator(It it) : it_(it) {}
305 constexpr cpp20_random_access_iterator& operator--() {
306 --it_;
310 constexpr cpp20_random_access_iterator operator--(int) { return cpp20_random_access_iterator(it_--); }
316 constexpr cpp20_random_access_iterator& operator-=(difference_type n) {
317 it_ -= n;
328 friend constexpr cpp20_random_access_iterator operator-(cpp20_random_access_iterator x, difference_type n) {
329 x -= n;
332 friend constexpr difference_type operator-(cpp20_random_access_iterator x, cpp20_random_access_iterator y) {
333 return x.it_ - y.it_;
355 friend constexpr It base(const cpp20_random_access_iterator& i) { return i.it_; }
360 template <class It>
361 cpp20_random_access_iterator(It) -> cpp20_random_access_iterator<It>;
365 template <std::contiguous_iterator It>
367 It it_;
375 using value_type = typename std::iterator_traits<It>::value_type;
376 using difference_type = typename std::iterator_traits<It>::difference_type;
377 using pointer = typename std::iterator_traits<It>::pointer;
378 using reference = typename std::iterator_traits<It>::reference;
381 constexpr It base() const { return it_; }
384 constexpr explicit contiguous_iterator(It it) : it_(it) {}
395 constexpr pointer operator->() const { return it_; }
402 constexpr contiguous_iterator& operator--() {
403 --it_;
407 constexpr contiguous_iterator operator--(int) { return contiguous_iterator(it_--); }
413 constexpr contiguous_iterator& operator-=(difference_type n) {
414 it_ -= n;
425 friend constexpr contiguous_iterator operator-(contiguous_iterator x, difference_type n) {
426 x -= n;
429 friend constexpr difference_type operator-(contiguous_iterator x, contiguous_iterator y) { return x.it_ - y.it_; }
448 friend constexpr It base(const contiguous_iterator& i) { return i.it_; }
453 template <class It>
454 contiguous_iterator(It) -> contiguous_iterator<It>;
456 template <class It>
459 static_assert(std::is_pointer_v<It>, "Things probably break in this case");
461 It it_;
467 typedef typename std::iterator_traits<It>::value_type value_type;
468 typedef typename std::iterator_traits<It>::difference_type difference_type;
469 typedef It pointer;
470 typedef typename std::iterator_traits<It>::reference reference;
471 typedef typename std::remove_pointer<It>::type element_type;
473 constexpr It base() const {return it_;}
476 constexpr explicit three_way_contiguous_iterator(It it) : it_(it) {}
489 constexpr pointer operator->() const {return it_;}
493 constexpr three_way_contiguous_iterator& operator--() {--it_; return *this;}
495 constexpr three_way_contiguous_iterator operator--(int) {return three_way_contiguous_iterator(it_--);}
498 constexpr three_way_contiguous_iterator& operator-=(difference_type n) {it_ -= n; return *this;}
501 friend constexpr three_way_contiguous_iterator operator-(three_way_contiguous_iterator x, difference_type n) {x -= n; return x;}
502 friend constexpr difference_type operator-(three_way_contiguous_iterator x, three_way_contiguous_iterator y) {return x.it_ - y.it_;}
510 template <class It>
511 three_way_contiguous_iterator(It) -> three_way_contiguous_iterator<It>;
536 if (action_ == TAAssignment && --index_ < 0) {
552 if (action_ == TADereference && --index_ < 0) {
563 if (action_ == TAIncrement && --index_ < 0) {
580 TEST_CONSTEXPR_CXX14 ThrowingIterator& operator--() {
581 if (action_ == TADecrement && --index_ < 0) {
588 --current_;
592 TEST_CONSTEXPR_CXX14 ThrowingIterator operator--(int) {
594 --(*this);
599 if (a.action_ == TAComparison && --a.index_ < 0) {
665 NonThrowingIterator & operator--() TEST_NOEXCEPT {
666 --current_;
670 NonThrowingIterator operator--(int) TEST_NOEXCEPT {
672 --(*this);
699 template <class It>
702 It it_;
706 using value_type = std::iter_value_t<It>;
707 using difference_type = std::iter_difference_t<It>;
710 constexpr explicit cpp20_input_iterator(It it) : it_(it) {}
717 friend constexpr It base(const cpp20_input_iterator& i) { return i.it_; }
722 template <class It>
723 cpp20_input_iterator(It) -> cpp20_input_iterator<It>;
735 template <class It>
737 It it_;
741 using difference_type = std::iter_difference_t<It>;
743 constexpr explicit cpp20_output_iterator(It it) : it_(it) {}
754 friend constexpr It base(const cpp20_output_iterator& i) { return i.it_; }
759 template <class It>
760 cpp20_output_iterator(It) -> cpp20_output_iterator<It>;
776 constexpr explicit common_input_iterator(Base it) : it_(it) {}
792 std::size_t increments = 0; ///< Number of times the iterator moved forward (++it, it++, it+=positive, it-=negative).
793 std::size_t decrements = 0; ///< Number of times the iterator moved backward (--it, it--, it-=positive, it+=negative).
794 std::size_t zero_moves = 0; ///< Number of times a call was made to move the iterator by 0 positions (it+=0, it-=0).
801 template <class It>
804 using value_type = typename iter_value_or_void<It>::type;
805 using difference_type = std::iter_difference_t<It>;
807 std::conditional_t<std::contiguous_iterator<It>, std::contiguous_iterator_tag,
808 std::conditional_t<std::random_access_iterator<It>, std::random_access_iterator_tag,
809 std::conditional_t<std::bidirectional_iterator<It>, std::bidirectional_iterator_tag,
810 std::conditional_t<std::forward_iterator<It>, std::forward_iterator_tag,
811 std::conditional_t<std::input_iterator<It>, std::input_iterator_tag,
817 requires std::default_initializable<It>
820 constexpr explicit operation_counting_iterator(It const& it, IteratorOpCounts* counts = nullptr)
821 : base_(base(it)), counts_(counts) {}
829 friend constexpr It base(operation_counting_iterator const& it) { return It(it.base_); }
831 constexpr decltype(auto) operator*() const { return *It(base_); }
833 constexpr decltype(auto) operator[](difference_type n) const { return It(base_)[n]; }
836 It tmp(base_);
845 requires std::forward_iterator<It>
852 constexpr operation_counting_iterator& operator--()
853 requires std::bidirectional_iterator<It>
855 It tmp(base_);
856 base_ = base(--tmp);
857 moved_by(-1);
861 constexpr operation_counting_iterator operator--(int)
862 requires std::bidirectional_iterator<It>
865 --*this;
870 requires std::random_access_iterator<It>
872 It tmp(base_);
878 constexpr operation_counting_iterator& operator-=(difference_type const n)
879 requires std::random_access_iterator<It>
881 It tmp(base_);
882 base_ = base(tmp -= n);
883 moved_by(-n);
887 friend constexpr operation_counting_iterator operator+(operation_counting_iterator it, difference_type n)
888 requires std::random_access_iterator<It>
890 return it += n;
893 friend constexpr operation_counting_iterator operator+(difference_type n, operation_counting_iterator it)
894 requires std::random_access_iterator<It>
896 return it += n;
899 friend constexpr operation_counting_iterator operator-(operation_counting_iterator it, difference_type n)
900 requires std::random_access_iterator<It>
902 return it -= n;
906 operator-(operation_counting_iterator const& x, operation_counting_iterator const& y)
907 requires std::sized_sentinel_for<It, It>
909 return base(x) - base(y);
914 ++counts_->equal_cmps;
918 requires std::sentinel_for<It, It>
921 return It(base_) == It(other.base_);
925 requires std::random_access_iterator<It>
927 return It(x.base_) < It(y.base_);
931 requires std::random_access_iterator<It>
933 return It(x.base_) > It(y.base_);
937 requires std::random_access_iterator<It>
939 return It(x.base_) <= It(y.base_);
943 requires std::random_access_iterator<It>
945 return It(x.base_) >= It(y.base_);
956 ++counts_->increments;
958 ++counts_->decrements;
960 ++counts_->zero_moves;
963 decltype(base(std::declval<It>())) base_;
966 template <class It>
967 operation_counting_iterator(It) -> operation_counting_iterator<It>;
972 template <class It>
976 constexpr explicit sentinel_wrapper(const It& it) : base_(base(it)) {}
977 constexpr bool operator==(const It& other) const {
985 friend constexpr It base(const sentinel_wrapper& s) { return It(s.base_); }
987 decltype(base(std::declval<It>())) base_;
989 template <class It>
990 sentinel_wrapper(It) -> sentinel_wrapper<It>;
992 template <class It>
996 constexpr explicit sized_sentinel(const It& it) : base_(base(it)) {}
997 constexpr bool operator==(const It& other) const { return base_ == base(other); }
998 friend constexpr auto operator-(const sized_sentinel& s, const It& i) { return s.base_ - base(i); }
999 friend constexpr auto operator-(const It& i, const sized_sentinel& s) { return base(i) - s.base_; }
1000 friend constexpr It base(const sized_sentinel& s) { return It(s.base_); }
1002 decltype(base(std::declval<It>())) base_;
1004 template <class It>
1005 sized_sentinel(It) -> sized_sentinel<It>;
1049 constexpr Iterator operator-(difference_type n) const {
1050 return Iterator(ptr_ - n, iter_moves_, iter_swaps_);
1052 constexpr difference_type operator-(Iterator rhs) const {
1053 return ptr_ - rhs.ptr_;
1059 constexpr Iterator& operator-=(difference_type n) {
1060 ptr_ -= n;
1071 constexpr Iterator& operator--() { --ptr_; return *this; }
1072 constexpr Iterator operator--(int) {
1074 --ptr_;
1112 constexpr rvalue_iterator(T* it) : it_(it) {}
1127 constexpr rvalue_iterator& operator--() {
1128 --it_;
1132 constexpr rvalue_iterator operator--(int) {
1134 --it_;
1140 tmp.it += n;
1149 constexpr rvalue_iterator operator-(difference_type n) const {
1151 tmp.it -= n;
1155 constexpr difference_type operator-(const rvalue_iterator& other) const { return it_ - other.it_; }
1162 constexpr rvalue_iterator& operator-=(difference_type n) {
1163 it_ -= n;
1176 rvalue_iterator(T*) -> rvalue_iterator<T>;
1182 // Proxy that can wrap a value or a reference. It simulates C++23's tuple
1185 // of swap to cause a compilation error if it's used in an algorithm that relies
1215 // This constructor covers conversion from cvref of Proxy<U>, including non-const/const versions of copy/move constructor
1235 // If `T` is a reference type, the implicitly-generated assignment operator will be deleted (and would take precedence
1236 // over the templated `operator=` above because it's a better match).
1262 // Helps compare e.g. `Proxy<int>` and `Proxy<int&>`. Note that the default 3-way comparison operator is deleted when
1286 // It wraps `Base` iterator and when dereferenced it returns a Proxy<ref>
1287 // It simulates C++23's zip_view::iterator but simplified to just wrap
1289 // Note it forwards value_type, iter_move, iter_swap. e.g if the base
1291 // operator* -> Proxy<int&>
1292 // iter_value_t -> Proxy<int>
1293 // iter_move -> Proxy<int&&>
1340 // Note std::move(*it) returns Proxy<Foo&>&&, which is not what we want as
1341 // it will likely result in a copy rather than a move
1348 // and std::swap takes non-const lvalue references
1377 constexpr ProxyIterator& operator--()
1379 --base_;
1383 constexpr ProxyIterator operator--(int)
1386 --*this;
1397 constexpr ProxyIterator& operator-=(difference_type n)
1399 base_ -= n;
1443 friend constexpr ProxyIterator operator-(const ProxyIterator& x, difference_type n)
1445 return ProxyIterator{x.base_ - n};
1448 friend constexpr difference_type operator-(const ProxyIterator& x, const ProxyIterator& y)
1450 return x.base_ - y.base_;
1454 ProxyIterator(Base) -> ProxyIterator<Base>;
1489 ProxySentinel(BaseSent) -> ProxySentinel<BaseSent>;
1513 ProxyRange(R&&) -> ProxyRange<std::views::all_t<R&&>>;
1554 Derived& operator--() {
1555 --iter_;
1559 Derived operator--(int) {
1561 --(*this);
1570 Derived& operator-=(difference_type i) {
1571 iter_ -= i;
1575 friend decltype(iter_ - iter_) operator-(const iterator_wrapper& lhs, const iterator_wrapper& rhs) {
1576 return lhs.iter_ - rhs.iter_;
1579 friend Derived operator-(Derived iter, difference_type i) {
1580 iter.iter_ -= i;
1628 : base(std::move(other)), moves_until_throw_(other.moves_until_throw_ - 1) {
1629 if (moves_until_throw_ == -1)
1634 moves_until_throw_ = other.moves_until_throw_ - 1;
1635 if (moves_until_throw_ == -1)
1642 throw_on_move_iterator(Iter) -> throw_on_move_iterator<Iter>;