Title: T[..; …] — A Non-owning Sized Arrays for Spans and Beyond
H1: T[..; …]
— Non-owning Sized Arrays for Spans and Beyond
Shortname: XXX7
Revision: 0
!Previous Revisions: None
Status: P
Date: 2024-01-02
Group: WG14
!Proposal Category: Change Request, Feature Request
!Target: C2y
Editor: JeanHeyd Meneide, phdofthehouse@gmail.com
Editor: Shepherd (Shepherd's Oasis LLC), shepherd@soasis.org
URL: https://thephd.dev/_vendor/future_cxx/papers/C%20-%20Non-owning%20Sized%20Arrays.html
!Paper Source: GitHub
Issue Tracking: GitHub https://github.com/ThePhD/future_cxx/issues
Metadata Order: Previous Revisions, Editor, This Version, Paper Source, Implementation, Issue Tracking, Project, Audience, Proposal Category, Target
Markup Shorthands: markdown yes
Toggle Diffs: no
Abstract: Modeled after the fix for what Walter Bright called "C's biggest mistake", this proposal explores an extended variant of a non-owning span type which can unify the processing of arrays, whether they're C arrays, a bespoke combination of a pointer and a size, a variable-length array, or other source/region of memory. The syntax, T[..]
, and it's expansive alternative that allows for an infinite amount of dimensions and strides within a single memory region, T[..; spec…]
, allow for code to very clearly model the semantics of a flat buffer of memory.
path: resources/css/bikeshed-wording.html
# Changelog # {#changelog}
- Initial release. ✨
# Introduction and Motivation # {#intro}
Ouiaf. :3
Wef! :3
# Design # {#design}
The syntax of this type is as specified below.
Syntax | Dimensions | Memory Regions | Minimum Storage required |
---|
`T a[..]` | 1 | 1 | 1 pointer, 1 size |
`T a[..][2]` | 2 | 2 | (1 pointer, 1 size) * 2 |
`T a[..][..]` | 2 | 1 * N | (1 pointer, 1 size) * N |
`T a[..; ..]` | 1 | 1 | 1 pointer, 1 size |
`T a[..; .., 4]` | 2 | 1 | 1 pointer, 1 size |
`T a[..; .., ..]` | 2 | 1 | 1 pointer, 2 sizes |
`T a[..; 3, .., 2]` | 3 | 1 | 1 pointer, 1 size |
`T a[..; .., .., ..]` | 3 | 1 | 1 pointer, 3 sizes |