Templates problem
pineapple via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Wed Sep 7 11:10:45 PDT 2016
On Tuesday, 6 September 2016 at 14:38:54 UTC, Russel Winder wrote:
> and I have no idea just now why it is complaining, nor what to
> do to fix it.
You might want to check out the ranges package of the library I'm
working on.
https://github.com/pineapplemachine/mach.d/tree/master/mach/range
This topic motivated me to see if my map function worked with
static arrays. Turns out that somehow I'd neglected to include a
unit test, and it in fact failed.
Once I've had a chance to commit the couple-line fix, probably in
a couple hours, this will be a valid program:
import mach.range : map;
import std.stdio : writeln;
void main(){
const(const(int)[3]) array = [1, 2, 3];
auto mapped = array.map!(e => e + 1);
mapped.front.writeln; // 2
mapped[0].writeln; // 2
// etc.
}
More information about the Digitalmars-d-learn
mailing list