[PATCH] libstdc++: Avoid hard error in ranges::unique_copy [PR100770]
Jonathan Wakely
jwakely.gcc@gmail.com
Wed May 26 19:55:22 GMT 2021
On Wed, 26 May 2021 at 20:11, Patrick Palka via Libstdc++
<libstdc++@gcc.gnu.org> wrote:
>
> On Wed, 26 May 2021, Tim Song wrote:
>
> > I noticed that output_iterator_wrapper still has a (non-void)
> > value_type. Perhaps we can get better coverage if it doesn't have one?
> > The existing tests should have caught this case with that change, at least.
>
> Good point, and I guess it should be fine to make its pointer and
> reference void as well. I'm testing:
Defining difference_type as void is also OK.
Before C++20 output iterators could define all of them as void. In
C++20 defining pointer as void means it doesn't support operator->(),
so either way it's OK for our output_iterator_wrapper.
> --- a/libstdc++-v3/testsuite/util/testsuite_iterators.h
> +++ b/libstdc++-v3/testsuite/util/testsuite_iterators.h
> @@ -122,7 +122,7 @@ namespace __gnu_test
> */
> template<class T>
> struct output_iterator_wrapper
> - : public std::iterator<std::output_iterator_tag, T, std::ptrdiff_t, T*, T&>
> + : public std::iterator<std::output_iterator_tag, void, std::ptrdiff_t, void, void>
> {
> protected:
> output_iterator_wrapper() : ptr(0), SharedInfo(0)
>
> >
> > On Wed, May 26, 2021 at 12:00 PM Patrick Palka via Libstdc++
> > <libstdc++@gcc.gnu.org> wrote:
> > >
> > > - else if constexpr (input_iterator<_Out>
> > > - && same_as<iter_value_t<_Iter>, iter_value_t<_Out>>)
> > > + else if constexpr (requires { requires (input_iterator<_Out>
> > > + && same_as<iter_value_t<_Iter>,
> > > + iter_value_t<_Out>>); })
> >
> > It's arguably cleaner to extract this into a concept which can then
> > also be used in the constraint.
>
> Sounds good, though I'm not sure what name to give to this relatively
> ad-hoc set of requirements. Any suggestions? :)
>
More information about the Libstdc++
mailing list