[libc++] Remove cpp17_input_iterator.h

Reviewed By: Quuxplusone, #libc

Spies: libcxx-commits

Differential Revision: https://reviews.llvm.org/D119881
This commit is contained in:
Nikolas Klauser 2022-02-15 21:52:21 +01:00
parent 2c58cde003
commit f75f171b20
5 changed files with 9 additions and 46 deletions

View File

@ -1,40 +0,0 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#ifndef INPUT_ITERATOR_H
#define INPUT_ITERATOR_H
#include <iterator>
template <class It>
class cpp17_input_iterator
{
It it_;
public:
typedef typename std::input_iterator_tag iterator_category;
typedef typename std::iterator_traits<It>::value_type value_type;
typedef typename std::iterator_traits<It>::difference_type difference_type;
typedef It pointer;
typedef typename std::iterator_traits<It>::reference reference;
cpp17_input_iterator() : it_() {}
explicit cpp17_input_iterator(It it) : it_(it) {}
reference operator*() const {return *it_;}
pointer operator->() const {return it_;}
cpp17_input_iterator& operator++() {++it_; return *this;}
cpp17_input_iterator operator++(int) {cpp17_input_iterator tmp(*this); ++(*this); return tmp;}
friend bool operator==(const cpp17_input_iterator& x, const cpp17_input_iterator& y)
{return x.it_ == y.it_;}
friend bool operator!=(const cpp17_input_iterator& x, const cpp17_input_iterator& y)
{return !(x == y);}
};
#endif // INPUT_ITERATOR_H

View File

@ -20,7 +20,7 @@
#include "test_macros.h"
#include "test_allocator.h"
#include "../cpp17_input_iterator.h"
#include "test_iterators.h"
#include "min_allocator.h"
template <class It>
@ -34,8 +34,11 @@ test(It first, It last)
LIBCPP_ASSERT(s2.__invariants());
assert(s2.size() == static_cast<std::size_t>(std::distance(first, last)));
unsigned i = 0;
for (It it = first; it != last; ++it, ++i)
for (It it = first; it != last;) {
assert(s2[i] == *it);
++it;
++i;
}
assert(s2.get_allocator() == A());
assert(s2.capacity() >= s2.size());
}
@ -50,8 +53,11 @@ test(It first, It last, const A& a)
LIBCPP_ASSERT(s2.__invariants());
assert(s2.size() == static_cast<std::size_t>(std::distance(first, last)));
unsigned i = 0;
for (It it = first; it != last; ++it, ++i)
for (It it = first; it != last;) {
assert(s2[i] == *it);
++it;
++i;
}
assert(s2.get_allocator() == a);
assert(s2.capacity() >= s2.size());
}

View File

@ -31,7 +31,6 @@
#include "test_macros.h"
#include "test_allocator.h"
#include "../cpp17_input_iterator.h"
#include "min_allocator.h"
bool test() {

View File

@ -33,7 +33,6 @@
#include "test_macros.h"
#include "test_allocator.h"
#include "../cpp17_input_iterator.h"
#include "min_allocator.h"
bool test() {

View File

@ -37,7 +37,6 @@
#include "test_macros.h"
#include "test_allocator.h"
#include "../cpp17_input_iterator.h"
#include "min_allocator.h"
bool test() {