Skip to content

Commit e777a40

Browse files
committed
Revert "add forward iterator"
This reverts commit a5ebf57f198cd79be132854b036f904c3983341d.
1 parent a29e01a commit e777a40

File tree

4 files changed

+12
-90
lines changed

4 files changed

+12
-90
lines changed

libc/benchmarks/gpu/LibcGpuBenchmark.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ void Benchmark::add_benchmark(Benchmark *benchmark) {
1313
}
1414

1515
void Benchmark::run_benchmarks() {
16-
for (Benchmark *benchmark : benchmarks)
17-
benchmark->run();
16+
for (auto it = benchmarks.rbegin(), e = benchmarks.rend(); it != e; ++it)
17+
(*it)->run();
1818
}
1919

2020
BenchmarkResult benchmark(const BenchmarkOptions &options,

libc/src/__support/CPP/array.h

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,10 @@ template <class T, size_t N> struct array {
2222

2323
T Data[N];
2424
using value_type = T;
25-
using pointer_type = T *;
26-
using iterator = cpp::iterator<pointer_type>;
27-
using const_pointer_type = const T *;
28-
using const_iterator = cpp::iterator<const_pointer_type>;
29-
using reverse_iterator = cpp::reverse_iterator<pointer_type>;
30-
using const_reverse_iterator = cpp::reverse_iterator<const_pointer_type>;
25+
using iterator = T *;
26+
using const_iterator = const T *;
27+
using reverse_iterator = cpp::reverse_iterator<iterator>;
28+
using const_reverse_iterator = cpp::reverse_iterator<const_iterator>;
3129

3230
LIBC_INLINE constexpr T *data() { return Data; }
3331
LIBC_INLINE constexpr const T *data() const { return Data; }
@@ -48,16 +46,12 @@ template <class T, size_t N> struct array {
4846

4947
LIBC_INLINE constexpr bool empty() const { return N == 0; }
5048

51-
LIBC_INLINE constexpr iterator begin() { return iterator{Data}; }
52-
LIBC_INLINE constexpr const_iterator begin() const {
53-
return const_iterator{Data};
54-
}
49+
LIBC_INLINE constexpr iterator begin() { return Data; }
50+
LIBC_INLINE constexpr const_iterator begin() const { return Data; }
5551
LIBC_INLINE constexpr const_iterator cbegin() const { return begin(); }
5652

57-
LIBC_INLINE constexpr iterator end() { return iterator{Data + N}; }
58-
LIBC_INLINE constexpr const_iterator end() const {
59-
return const_iterator{Data + N};
60-
}
53+
LIBC_INLINE constexpr iterator end() { return Data + N; }
54+
LIBC_INLINE constexpr const_iterator end() const { return Data + N; }
6155
LIBC_INLINE constexpr const_iterator cend() const { return end(); }
6256

6357
LIBC_INLINE constexpr reverse_iterator rbegin() {
@@ -71,10 +65,10 @@ template <class T, size_t N> struct array {
7165
}
7266

7367
LIBC_INLINE constexpr reverse_iterator rend() {
74-
return reverse_iterator{Data};
68+
return reverse_iterator{begin()};
7569
}
7670
LIBC_INLINE constexpr const_reverse_iterator rend() const {
77-
return const_reverse_iterator{Data};
71+
return const_reverse_iterator{begin()};
7872
}
7973
LIBC_INLINE constexpr const_reverse_iterator crend() const { return rend(); }
8074
};

libc/src/__support/CPP/iterator.h

Lines changed: 0 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -92,74 +92,6 @@ template <typename Iter> class reverse_iterator {
9292
}
9393
};
9494

95-
template <typename Iter> class iterator {
96-
Iter current;
97-
98-
public:
99-
using reference = typename iterator_traits<Iter>::reference;
100-
using value_type = typename iterator_traits<Iter>::value_type;
101-
using iterator_type = Iter;
102-
103-
LIBC_INLINE iterator() : current() {}
104-
LIBC_INLINE constexpr explicit iterator(Iter it) : current(it) {}
105-
106-
template <typename Other,
107-
cpp::enable_if_t<!cpp::is_same_v<Iter, Other> &&
108-
cpp::is_convertible_v<const Other &, Iter>,
109-
int> = 0>
110-
LIBC_INLINE constexpr explicit iterator(const Other &it) : current(it) {}
111-
112-
LIBC_INLINE friend constexpr bool operator==(const iterator &lhs,
113-
const iterator &rhs) {
114-
return lhs.base() == rhs.base();
115-
}
116-
117-
LIBC_INLINE friend constexpr bool operator!=(const iterator &lhs,
118-
const iterator &rhs) {
119-
return lhs.base() != rhs.base();
120-
}
121-
122-
LIBC_INLINE friend constexpr bool operator<(const iterator &lhs,
123-
const iterator &rhs) {
124-
return lhs.base() < rhs.base();
125-
}
126-
127-
LIBC_INLINE friend constexpr bool operator<=(const iterator &lhs,
128-
const iterator &rhs) {
129-
return lhs.base() <= rhs.base();
130-
}
131-
132-
LIBC_INLINE friend constexpr bool operator>(const iterator &lhs,
133-
const iterator &rhs) {
134-
return lhs.base() > rhs.base();
135-
}
136-
137-
LIBC_INLINE friend constexpr bool operator>=(const iterator &lhs,
138-
const iterator &rhs) {
139-
return lhs.base() >= rhs.base();
140-
}
141-
142-
LIBC_INLINE constexpr iterator_type base() const { return current; }
143-
144-
LIBC_INLINE constexpr reference operator*() const {
145-
Iter tmp = current;
146-
return *tmp;
147-
}
148-
LIBC_INLINE constexpr iterator operator--() {
149-
--current;
150-
return *this;
151-
}
152-
LIBC_INLINE constexpr iterator &operator++() {
153-
++current;
154-
return *this;
155-
}
156-
LIBC_INLINE constexpr iterator operator++(int) {
157-
iterator tmp(*this);
158-
++current;
159-
return tmp;
160-
}
161-
};
162-
16395
} // namespace cpp
16496
} // namespace LIBC_NAMESPACE
16597

libc/src/__support/fixedvector.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,6 @@ template <typename T, size_t CAPACITY> class FixedVector {
5858
// can easily swap one data structure for the other.
5959
static void destroy(FixedVector<T, CAPACITY> *store) { store->reset(); }
6060

61-
using iterator = typename cpp::array<T, CAPACITY>::iterator;
62-
LIBC_INLINE constexpr iterator begin() { return iterator{&store[0]}; }
63-
LIBC_INLINE constexpr iterator end() { return iterator{&store[item_count]}; }
64-
6561
using reverse_iterator = typename cpp::array<T, CAPACITY>::reverse_iterator;
6662
LIBC_INLINE constexpr reverse_iterator rbegin() {
6763
return reverse_iterator{&store[item_count]};

0 commit comments

Comments
 (0)