On Wed, 31 Aug 2022 at 14:30, Patrick Palka <ppa...@redhat.com> wrote: > > On Wed, 31 Aug 2022, Jonathan Wakely wrote: > > > On Tue, 30 Aug 2022 at 18:14, Patrick Palka via Libstdc++ > > <libstd...@gcc.gnu.org> wrote: > > > > > > Tested on x86_64-pc-linux-gnu, does this look OK for trunk? > > > > > > > + constexpr > > > + _Iterator(__as_sentinel, iterator_t<_Base> __first, > > > iterator_t<_Base> __last) > > > + { > > > + if constexpr (!bidirectional_range<_Base>) > > > + for (auto& __it : _M_current) > > > + __it = __last; > > > + else > > > + for (ssize_t __i = _Nm-1; __i >= 0; --__i) > > > > ssize_t is defined by POSIX in <sys/types.h> but isn't in ISO C or > > C++. It looks like MinGW defines it to ... something ... sometimes, > > but I don't think we can rely on it for non-POSIX targets. > > I see. Using ssize_t makes the loop a little cleaner but it's hardly > necessary, so consider it rewritten into: > > for (size_t __i = 0; __i < _Nm; ++__i) > { > _M_current[_Nm - 1 - __i] = __last; > ranges::advance(__last, -1, __first); > } > > > > > > > > + template<size_t _Nm> > > > + struct _Adjacent : __adaptor::_RangeAdaptorClosure > > > + { > > > + template<viewable_range _Range> > > > + requires (_Nm == 0) || __detail::__can_adjacent_view<_Nm, > > > _Range> > > > + [[nodiscard]] > > > + constexpr auto > > > + operator()(_Range&& __r) const > > > > Does this attribute actually work here? > > > > I thought we needed to use `operator() [[nodiscard]]` for functions > > with a requires-clause, because otherwise the attribute gives a parse > > error. Maybe I've misremembered the problem, and it just doesn't give > > a -Wunused-result warning. The decl above is setting off my spidey > > sense for some reason though. > > Oops yeah, it looks like this position of [[nodiscard]] works with > standard concepts, but it's a parse error with -fconcepts-ts due to the > different requires-clause grammar. > > Here's v2 which avoids using ssize_t, and puts the [[nodiscard]] after > 'operator()' (_Zip and _ZipTransform have the same issue which I can > fix separately):
OK for trunk with those changes, thanks.