2020-03-04 Patrick Palka <ppalka@redhat.com>
+ * testsuite/util/testsuite_iterators.h (test_range::get_iterator): Make
+ protected instead of private.
+ (test_sized_range_sized_sent): New.
+
* testsuite/util/testsuite_iterators.h (input_iterator_wrapper_nocopy):
New testsuite iterator.
* testsuite/24_iterators/counted_iterator/lwg3389.cc: use it.
{ return i.ptr - s.end; }
};
+ protected:
auto
get_iterator(T* p)
{
using test_output_sized_range
= test_sized_range<T, output_iterator_wrapper>;
+ // A type meeting the minimum std::sized_range requirements, and whose end()
+ // returns a sized sentinel.
+ template<typename T, template<typename> class Iter>
+ struct test_sized_range_sized_sent : test_sized_range<T, Iter>
+ {
+ using test_sized_range<T, Iter>::test_sized_range;
+
+ template<typename I>
+ struct sentinel
+ {
+ T* end;
+
+ friend bool operator==(const sentinel& s, const I& i) noexcept
+ { return s.end == i.ptr; }
+
+ friend std::iter_difference_t<I>
+ operator-(const sentinel& s, const I& i) noexcept
+ { return s.end - i.ptr; }
+
+ friend std::iter_difference_t<I>
+ operator-(const I& i, const sentinel& s) noexcept
+ { return i.ptr - s.end; }
+ };
+
+ auto end() &
+ {
+ using I = decltype(this->get_iterator(this->bounds.last));
+ return sentinel<I>{this->bounds.last};
+ }
+ };
+
// test_range and test_sized_range do not own their elements, so they model
// std::ranges::borrowed_range. This file does not define specializations of
// std::ranges::enable_borrowed_range, so that individual tests can decide