@Pilar, this is the patch. Let me know if you need any help or have questions. Thank you !
On Mon 3. Jul 2023 at 09:02, Gonzalo Brito Gadeschi < gonzalo.gades...@gmail.com> wrote: > libstdc++: Recognize C++ random access iterators as random access in PSTL > [PR110432] > > The check for random access iterators in the PSTL only checks whether the > iterator inherits from the random_access_iterator_tag, failing to recognize > random access iterators originating in C++20 ranges and views. > > This patch extends the check to also recognize types that model the C++20 > random_access_iterator concept as providing random access. > > This is allowed by C++23's P2408, which is safe to backport to C++20, > because > any application that would break already exhibits undefined > behavior due to precondition violation. > > libstdc++-v3/ChangeLog: > PR libstdc++/110512 > * include/pstl/execution_impl.h Recognize C++20 random access iterators as > random access. > > Bootstrapping and testing > * Tested with x86_64-pc-linux-gnu. > > --- > libstdc++-v3/include/pstl/execution_impl.h | 10 +++++++++- > 1 file changed, 9 insertions(+), 1 deletion(-) > > diff --git a/libstdc++-v3/include/pstl/execution_impl.h > b/libstdc++-v3/include/pstl/execution_impl.h > index 64f6cc4357a..c17da29141e 100644 > --- a/libstdc++-v3/include/pstl/execution_impl.h > +++ b/libstdc++-v3/include/pstl/execution_impl.h > @@ -22,7 +22,15 @@ namespace __internal > > template <typename _IteratorTag, typename... _IteratorTypes> > using __are_iterators_of = std::conjunction< > - std::is_base_of<_IteratorTag, typename > std::iterator_traits<std::decay_t<_IteratorTypes>>::iterator_category>...>; > +#if __cplusplus >= 202002L > + std::disjunction< > + std::is_base_of<_IteratorTag, typename > std::iterator_traits<std::decay_t<_IteratorTypes>>::iterator_category>, > + std::integral_constant<bool, > std::random_access_iterator<_IteratorTypes>> > + >... > +#else // __cplusplus > + std::is_base_of<_IteratorTag, typename > std::iterator_traits<std::decay_t<_IteratorTypes>>::iterator_category>... > +#endif // __cplusplus > +>; > > template <typename... _IteratorTypes> > using __are_random_access_iterators = > __are_iterators_of<std::random_access_iterator_tag, _IteratorTypes...>; > > -- > 2.17.1 >