forked from OSchip/llvm-project
[libc++][NFC] Remove duplication of distance_apriori_sentinel
This commit is contained in:
parent
1e04923d21
commit
c7aa8b2962
|
@ -18,33 +18,10 @@
|
|||
#include <climits>
|
||||
|
||||
#include "test_iterators.h"
|
||||
#include "../types.h"
|
||||
|
||||
using range_t = std::array<int, 10>;
|
||||
|
||||
class distance_apriori_sentinel {
|
||||
public:
|
||||
distance_apriori_sentinel() = default;
|
||||
constexpr explicit distance_apriori_sentinel(std::ptrdiff_t const count) : count_(count) {}
|
||||
|
||||
constexpr bool operator==(std::input_or_output_iterator auto const&) const {
|
||||
assert(false && "difference op should take precedence");
|
||||
return false;
|
||||
}
|
||||
|
||||
friend constexpr std::ptrdiff_t operator-(std::input_or_output_iterator auto const&,
|
||||
distance_apriori_sentinel const y) {
|
||||
return -y.count_;
|
||||
}
|
||||
|
||||
friend constexpr std::ptrdiff_t operator-(distance_apriori_sentinel const x,
|
||||
std::input_or_output_iterator auto const&) {
|
||||
return x.count_;
|
||||
}
|
||||
|
||||
private:
|
||||
std::ptrdiff_t count_ = 0;
|
||||
};
|
||||
|
||||
struct expected_t {
|
||||
range_t::const_iterator coordinate;
|
||||
std::ptrdiff_t result;
|
||||
|
|
|
@ -18,33 +18,10 @@
|
|||
#include <cstddef>
|
||||
|
||||
#include "test_iterators.h"
|
||||
#include "../types.h"
|
||||
|
||||
using range_t = std::array<int, 10>;
|
||||
|
||||
class distance_apriori_sentinel {
|
||||
public:
|
||||
distance_apriori_sentinel() = default;
|
||||
constexpr explicit distance_apriori_sentinel(std::ptrdiff_t const count) : count_(count) {}
|
||||
|
||||
constexpr bool operator==(std::input_or_output_iterator auto const&) const {
|
||||
assert(false && "difference op should take precedence");
|
||||
return false;
|
||||
}
|
||||
|
||||
friend constexpr std::ptrdiff_t operator-(std::input_or_output_iterator auto const&,
|
||||
distance_apriori_sentinel const y) {
|
||||
return -y.count_;
|
||||
}
|
||||
|
||||
friend constexpr std::ptrdiff_t operator-(distance_apriori_sentinel const x,
|
||||
std::input_or_output_iterator auto const&) {
|
||||
return x.count_;
|
||||
}
|
||||
|
||||
private:
|
||||
std::ptrdiff_t count_ = 0;
|
||||
};
|
||||
|
||||
template <class It, class Sent = It>
|
||||
constexpr void check_assignable_case() {
|
||||
auto range = range_t{0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include <utility>
|
||||
|
||||
#include "test_iterators.h"
|
||||
#include "../types.h"
|
||||
|
||||
using range_t = std::array<int, 10>;
|
||||
|
||||
|
@ -35,30 +36,6 @@ private:
|
|||
decltype(base(std::declval<It>())) base_;
|
||||
};
|
||||
|
||||
class distance_apriori_sentinel {
|
||||
public:
|
||||
distance_apriori_sentinel() = default;
|
||||
constexpr explicit distance_apriori_sentinel(std::ptrdiff_t const count) : count_(count) {}
|
||||
|
||||
constexpr bool operator==(std::input_or_output_iterator auto const&) const {
|
||||
assert(false && "difference op should take precedence");
|
||||
return false;
|
||||
}
|
||||
|
||||
friend constexpr std::ptrdiff_t operator-(std::input_or_output_iterator auto const&,
|
||||
distance_apriori_sentinel const y) {
|
||||
return -y.count_;
|
||||
}
|
||||
|
||||
friend constexpr std::ptrdiff_t operator-(distance_apriori_sentinel const x,
|
||||
std::input_or_output_iterator auto const&) {
|
||||
return x.count_;
|
||||
}
|
||||
|
||||
private:
|
||||
std::ptrdiff_t count_ = 0;
|
||||
};
|
||||
|
||||
template <bool Count, typename It>
|
||||
constexpr void check_assignable(int* it, int* last, int const* expected) {
|
||||
{
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 TEST_STD_ITERATORS_ITERATOR_PRIMITIVES_RANGE_ITER_OPS_TYPES_H
|
||||
#define TEST_STD_ITERATORS_ITERATOR_PRIMITIVES_RANGE_ITER_OPS_TYPES_H
|
||||
|
||||
#include <cassert>
|
||||
#include <cstddef>
|
||||
#include <iterator>
|
||||
|
||||
class distance_apriori_sentinel {
|
||||
public:
|
||||
distance_apriori_sentinel() = default;
|
||||
constexpr explicit distance_apriori_sentinel(std::ptrdiff_t const count) : count_(count) {}
|
||||
|
||||
constexpr bool operator==(std::input_or_output_iterator auto const&) const {
|
||||
assert(false && "difference op should take precedence");
|
||||
return false;
|
||||
}
|
||||
|
||||
friend constexpr std::ptrdiff_t operator-(std::input_or_output_iterator auto const&,
|
||||
distance_apriori_sentinel const y) {
|
||||
return -y.count_;
|
||||
}
|
||||
|
||||
friend constexpr std::ptrdiff_t operator-(distance_apriori_sentinel const x,
|
||||
std::input_or_output_iterator auto const&) {
|
||||
return x.count_;
|
||||
}
|
||||
|
||||
private:
|
||||
std::ptrdiff_t count_ = 0;
|
||||
};
|
||||
|
||||
#endif // TEST_STD_ITERATORS_ITERATOR_PRIMITIVES_RANGE_ITER_OPS_TYPES_H
|
Loading…
Reference in New Issue