libstdc++ correctness fix for layout_stride::mapping uniqueness check
Corrects the uniqueness check for `layout_stride::mapping` in C++20 ranges, resolving LWG4606 and accepting valid mappings.
GCC’s libstdc++ has corrected the implementation of the uniqueness check for std::ranges::stride::mapping to align with the C++20 standard (LWG4606). The previous implementation incorrectly rejected some valid stride combinations. The fix accurately calculates the required span size for new mappings derived from existing ones, ensuring that the stride of a newly added dimension is sufficiently large. It also handles dimensions with an extent of one and zero strides more correctly.
In Details
This change in libstdc++ addresses LWG issue 4606 concerning std::ranges::stride_view::mapping::unique(). The logic for determining uniqueness of a mapping, particularly when extending a mapping with a new dimension, was flawed. The corrected implementation uses the relationship new_stride >= current_span_size to ensure uniqueness. It correctly handles dimensions with extent 1 by separating them and processing their strides later, and also refines the handling of zero strides to be permissible only for dimensions with extent 1.
- libstdc++
- The C++ Standard Library implementation used by GCC, providing standard containers, algorithms, and I/O facilities.
- layout_stride::mapping
- A component within C++20 ranges related to stride views, which describes how elements are accessed in a strided manner. The mapping defines extents and strides for dimensions.
- C++20 ranges
- A feature introduced in C++20 that provides a modern way to work with sequences of elements, offering a more composable and expressive API for iteration and views.
- LWG4606
- A defect report against the C++ standard library, specifically concerning the uniqueness check for
stride_view::mappingin C++20. - stride
- In the context of data access, the number of elements to skip between consecutive accessed items along a particular dimension.