Bug 13591 – [Enh] add std.algorithm.reinterpret

Status
NEW
Severity
enhancement
Priority
P4
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-10-09T00:16:56Z
Last change time
2024-12-01T16:22:39Z
Assigned to
No Owner
Creator
Walter Bright
Moved to GitHub: phobos#10091 →

Comments

Comment #0 by bugzilla — 2014-10-09T00:16:56Z
Currently, it is clumsy to change the type of an Element in a pipeline, as a map algorithm is needed. This algorithm does that in one simple operation: a.b.reinterpret!T.c.d ... It "paints" the Element type E of its input range to a new type T and presents an input range with the new type. The original and new types must be the same size, or an assert happens. Painting does not change the bits. (Hence this is unsafe when painting an int into a pointer.) reinterpret should be lazy, pure, @nogc and nothrow. CTFE has limited support for painting, such as painting float <=> int, the implementation must ensure that CTFE is working on it.
Comment #1 by monarchdodra — 2014-10-09T08:11:07Z
Sounds like the first step here would be to have an actual (safe/verified) reinterpretCast ?
Comment #2 by greensunny12 — 2018-02-10T19:57:40Z
> Currently, it is clumsy to change the type of an Element in a pipeline Well, the status quo for whole elements a.b.pipe!(a => cast(T)).c.d And for elements: a.b.map!(a => cast(T)).c.d Or is this just a request to generalize std.exception.assumeUnique into assume!XYZ, but being @safe for all its generalizations?
Comment #3 by robert.schadek — 2024-12-01T16:22:39Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/phobos/issues/10091 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB