[PATCH v1 0/3] Implement aligned_accessor [P2897R7].
Luc Grosheintz
luc.grosheintz@gmail.com
Thu Jul 3 10:33:44 GMT 2025
This patch series implements the aligned_accessor paper P2897R7 in three
parts:
- Implement `is_sufficiently_aligned` which is part of <memory>.
- Prepare the accessor tests for reuse.
- Implement aligned_accessor.
A couple of remarks:
- The paper P2897R7 and spec N5008 don't specify that the aligment
for is_sufficiently_aligned must be a power of two.
- The reasoning for why is_sufficiently_aligned isn't constexpr is
nicely described in the paper.
- Use of `class` in is_sufficiently_aligned is for consistency within
that file.
- The tests create new unsupported tests and expected failures. The
testsuite doesn't have all that many of those; so there's likely a
strategy to avoid this. However, I don't know how.
- These changes are independent of mdspan, but due to the precise
location of the code it might conflict with the mdspan patch series.
- I skipped updating `cxxapi-data.csv` for is_sufficiently_aligned
due to consistency with the rest of the mdspan patches, i.e. there
will be a bulk update of the file later.
- Each commit was tested with/without PCH and with/without
_GLIBCXX_DEBUG filtered by 20_util/is_sufficiently_aligned
and 23_containers/mdspan.
The last commit was tested fully with/without PCH. All tests on
x86_64-linux.
As always I'm happy to reorganize into different commits, if the
grouping doesn't make sense.
Luc Grosheintz (3):
libstdc++: Implement is_sufficiently_aligned.
libstdc++: Prepare test code for default_accessor for reuse.
libstdc++: Implement aligned_accessor from mdspan.
libstdc++-v3/include/bits/align.h | 16 ++
libstdc++-v3/include/bits/version.def | 18 ++
libstdc++-v3/include/bits/version.h | 20 +++
libstdc++-v3/include/std/mdspan | 72 ++++++++
libstdc++-v3/include/std/memory | 1 +
libstdc++-v3/src/c++23/std.cc.in | 4 +-
.../20_util/is_sufficiently_aligned/1.cc | 31 ++++
.../20_util/is_sufficiently_aligned/2.cc | 7 +
.../23_containers/mdspan/accessors/aligned.cc | 43 +++++
.../mdspan/accessors/aligned_ftm.cc | 6 +
.../mdspan/accessors/aligned_neg.cc | 33 ++++
.../accessors/debug/aligned_access_neg.cc | 23 +++
.../accessors/debug/aligned_offset_neg.cc | 23 +++
.../23_containers/mdspan/accessors/default.cc | 99 -----------
.../23_containers/mdspan/accessors/generic.cc | 168 ++++++++++++++++++
15 files changed, 464 insertions(+), 100 deletions(-)
create mode 100644 libstdc++-v3/testsuite/20_util/is_sufficiently_aligned/1.cc
create mode 100644 libstdc++-v3/testsuite/20_util/is_sufficiently_aligned/2.cc
create mode 100644 libstdc++-v3/testsuite/23_containers/mdspan/accessors/aligned.cc
create mode 100644 libstdc++-v3/testsuite/23_containers/mdspan/accessors/aligned_ftm.cc
create mode 100644 libstdc++-v3/testsuite/23_containers/mdspan/accessors/aligned_neg.cc
create mode 100644 libstdc++-v3/testsuite/23_containers/mdspan/accessors/debug/aligned_access_neg.cc
create mode 100644 libstdc++-v3/testsuite/23_containers/mdspan/accessors/debug/aligned_offset_neg.cc
delete mode 100644 libstdc++-v3/testsuite/23_containers/mdspan/accessors/default.cc
create mode 100644 libstdc++-v3/testsuite/23_containers/mdspan/accessors/generic.cc
--
2.49.0
More information about the Libstdc++
mailing list