forked from OSchip/llvm-project
[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:
parent
2c58cde003
commit
f75f171b20
|
@ -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
|
|
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
#include "test_macros.h"
|
#include "test_macros.h"
|
||||||
#include "test_allocator.h"
|
#include "test_allocator.h"
|
||||||
#include "../cpp17_input_iterator.h"
|
#include "test_iterators.h"
|
||||||
#include "min_allocator.h"
|
#include "min_allocator.h"
|
||||||
|
|
||||||
template <class It>
|
template <class It>
|
||||||
|
@ -34,8 +34,11 @@ test(It first, It last)
|
||||||
LIBCPP_ASSERT(s2.__invariants());
|
LIBCPP_ASSERT(s2.__invariants());
|
||||||
assert(s2.size() == static_cast<std::size_t>(std::distance(first, last)));
|
assert(s2.size() == static_cast<std::size_t>(std::distance(first, last)));
|
||||||
unsigned i = 0;
|
unsigned i = 0;
|
||||||
for (It it = first; it != last; ++it, ++i)
|
for (It it = first; it != last;) {
|
||||||
assert(s2[i] == *it);
|
assert(s2[i] == *it);
|
||||||
|
++it;
|
||||||
|
++i;
|
||||||
|
}
|
||||||
assert(s2.get_allocator() == A());
|
assert(s2.get_allocator() == A());
|
||||||
assert(s2.capacity() >= s2.size());
|
assert(s2.capacity() >= s2.size());
|
||||||
}
|
}
|
||||||
|
@ -50,8 +53,11 @@ test(It first, It last, const A& a)
|
||||||
LIBCPP_ASSERT(s2.__invariants());
|
LIBCPP_ASSERT(s2.__invariants());
|
||||||
assert(s2.size() == static_cast<std::size_t>(std::distance(first, last)));
|
assert(s2.size() == static_cast<std::size_t>(std::distance(first, last)));
|
||||||
unsigned i = 0;
|
unsigned i = 0;
|
||||||
for (It it = first; it != last; ++it, ++i)
|
for (It it = first; it != last;) {
|
||||||
assert(s2[i] == *it);
|
assert(s2[i] == *it);
|
||||||
|
++it;
|
||||||
|
++i;
|
||||||
|
}
|
||||||
assert(s2.get_allocator() == a);
|
assert(s2.get_allocator() == a);
|
||||||
assert(s2.capacity() >= s2.size());
|
assert(s2.capacity() >= s2.size());
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,6 @@
|
||||||
|
|
||||||
#include "test_macros.h"
|
#include "test_macros.h"
|
||||||
#include "test_allocator.h"
|
#include "test_allocator.h"
|
||||||
#include "../cpp17_input_iterator.h"
|
|
||||||
#include "min_allocator.h"
|
#include "min_allocator.h"
|
||||||
|
|
||||||
bool test() {
|
bool test() {
|
||||||
|
|
|
@ -33,7 +33,6 @@
|
||||||
|
|
||||||
#include "test_macros.h"
|
#include "test_macros.h"
|
||||||
#include "test_allocator.h"
|
#include "test_allocator.h"
|
||||||
#include "../cpp17_input_iterator.h"
|
|
||||||
#include "min_allocator.h"
|
#include "min_allocator.h"
|
||||||
|
|
||||||
bool test() {
|
bool test() {
|
||||||
|
|
|
@ -37,7 +37,6 @@
|
||||||
|
|
||||||
#include "test_macros.h"
|
#include "test_macros.h"
|
||||||
#include "test_allocator.h"
|
#include "test_allocator.h"
|
||||||
#include "../cpp17_input_iterator.h"
|
|
||||||
#include "min_allocator.h"
|
#include "min_allocator.h"
|
||||||
|
|
||||||
bool test() {
|
bool test() {
|
||||||
|
|
Loading…
Reference in New Issue