Skip to content
This repository has been archived by the owner on Sep 18, 2024. It is now read-only.

P1684: Avoid users needing to specify required span size twice #15

Open
mhoemmen opened this issue Apr 23, 2022 · 1 comment
Open

P1684: Avoid users needing to specify required span size twice #15

mhoemmen opened this issue Apr 23, 2022 · 1 comment
Labels
P1684 Issues in P1684, the specification of mdarray

Comments

@mhoemmen
Copy link
Contributor

This comes from 1684R2 LEWG review on 2022/04/19.

If users want to use std::array as mdarray's Container, they currently need to specify the size as part of the Container's type. If the size is too small, it's UB. For common use cases (layout_{left,right} with all compile-time extents), mdarray can compute the correct minimum size (via required_span_size()) at compile time. Users shouldn't have to repeat themselves (Don't Repeat Yourself principle).

One suggested fix was to provide a template type alias that deduces the correct std::array type from ElementType and SizeTypes..., at least for common layouts (perhaps layout_{left,right} only). A more comprehensive fix would make the default value of Container a function of all the previous template parameters. There would be no need to make that policy customizable, as users could always explicitly specify the Container type (and write their own policy to deduce it).

@mhoemmen mhoemmen added the P1684 Issues in P1684, the specification of mdarray label Apr 23, 2022
@crtrott
Copy link
Member

crtrott commented Apr 24, 2022

Why is it easier to write: array<T,static_extent_function(N0,N1,N2,N3)> then array<T,N0*N1*N2*N3> ? in particular since this would only work for layout_right, layout_left.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
P1684 Issues in P1684, the specification of mdarray
Projects
None yet
Development

No branches or pull requests

2 participants