digitalmars.D.bugs - [Issue 13591] New: [Enh] add std.algorithm.reinterpret
- via Digitalmars-d-bugs (24/24) Oct 08 2014 https://issues.dlang.org/show_bug.cgi?id=13591
https://issues.dlang.org/show_bug.cgi?id=13591 Issue ID: 13591 Summary: [Enh] add std.algorithm.reinterpret Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: enhancement Priority: P1 Component: Phobos Assignee: nobody puremagic.com Reporter: bugzilla digitalmars.com 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. --
Oct 08 2014