Message ID | 20200303163043.2182013-3-ppalka@redhat.com |
---|---|
State | New |
Headers | show |
Series | [1/4] libstdc++: Fix use of is_nothrow_assignable_v in <bits/ranges_uninitialized.h> | expand |
On 03/03/20 11:30 -0500, Patrick Palka wrote: >This adds a test range type whose end() is a sized sentinel to ><testsuite_iterators.h>, which will be used in the tests that verify LWG 3355. > >libstdc++-v3/ChangeLog: > > * 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 | 32 +++++++++++++++++++ > 1 file changed, 32 insertions(+) > >diff --git a/libstdc++-v3/testsuite/util/testsuite_iterators.h b/libstdc++-v3/testsuite/util/testsuite_iterators.h >index e47b2b03e40..756940ed092 100644 >--- a/libstdc++-v3/testsuite/util/testsuite_iterators.h >+++ b/libstdc++-v3/testsuite/util/testsuite_iterators.h >@@ -735,6 +735,7 @@ namespace __gnu_test > { return i.ptr - s.end; } > }; > >+ protected: > auto > get_iterator(T* p) > { >@@ -812,6 +813,37 @@ namespace __gnu_test > 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 size sentinel. s/size/sized/ here, no? OK for master.
On Tue, 3 Mar 2020, Jonathan Wakely wrote: > On 03/03/20 11:30 -0500, Patrick Palka wrote: > > This adds a test range type whose end() is a sized sentinel to > > <testsuite_iterators.h>, which will be used in the tests that verify LWG > > 3355. > > > > libstdc++-v3/ChangeLog: > > > > * 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 | 32 +++++++++++++++++++ > > 1 file changed, 32 insertions(+) > > > > diff --git a/libstdc++-v3/testsuite/util/testsuite_iterators.h > > b/libstdc++-v3/testsuite/util/testsuite_iterators.h > > index e47b2b03e40..756940ed092 100644 > > --- a/libstdc++-v3/testsuite/util/testsuite_iterators.h > > +++ b/libstdc++-v3/testsuite/util/testsuite_iterators.h > > @@ -735,6 +735,7 @@ namespace __gnu_test > > { return i.ptr - s.end; } > > }; > > > > + protected: > > auto > > get_iterator(T* p) > > { > > @@ -812,6 +813,37 @@ namespace __gnu_test > > 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 size sentinel. > > s/size/sized/ here, no? > > OK for master. Thanks for the review. I committed this series with that change just now.
diff --git a/libstdc++-v3/testsuite/util/testsuite_iterators.h b/libstdc++-v3/testsuite/util/testsuite_iterators.h index e47b2b03e40..756940ed092 100644 --- a/libstdc++-v3/testsuite/util/testsuite_iterators.h +++ b/libstdc++-v3/testsuite/util/testsuite_iterators.h @@ -735,6 +735,7 @@ namespace __gnu_test { return i.ptr - s.end; } }; + protected: auto get_iterator(T* p) { @@ -812,6 +813,37 @@ namespace __gnu_test 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 size 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