Bug 21100 – The internal data of std.container.array.Array cannot be referenced.

Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2020-08-02T08:57:01Z
Last change time
2021-07-21T05:08:43Z
Assigned to
No Owner
Creator
SHOO

Comments

Comment #0 by zan77137 — 2020-08-02T08:57:01Z
In after C++11 std::vector, it defines data() function to retrieve internal data. http://www.cplusplus.com/reference/vector/vector/data/ It would be a convenience to make it available in std.container.array.Array as well, with @system and a clear indication that dangling is a possibility. This feature is useful for making simple dump files and interfacing with C. Also, in the case of simple byte sequence memory operations, it is expected to be faster than Range.
Comment #1 by dlang-bugzilla — 2021-07-06T05:10:54Z
You can use (&arr[0])[0 .. arr.length].
Comment #2 by dandrei279 — 2021-07-20T17:49:13Z
I opened a PR [0] regarding this. [0] https://github.com/dlang/phobos/pull/8174
Comment #3 by dandrei279 — 2021-07-21T05:08:43Z
PR [0] was merged into master. [0] https://github.com/dlang/phobos/pull/8174