[Issue 12869] New: std.algorithm.sum for core.simd too

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Fri Jun 6 10:19:45 PDT 2014


https://issues.dlang.org/show_bug.cgi?id=12869

          Issue ID: 12869
           Summary: std.algorithm.sum for core.simd too
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: Phobos
          Assignee: nobody at puremagic.com
          Reporter: bearophile_hugs at eml.cc

I suggest to support simd values from sum, because this is a common operation:

void main() {
    import core.simd: int4;
    import std.algorithm: sum;
    int4 x = [1, 2, 3, 4];
    int total = x.sum;
}


A workaround is to use this, that is not efficient:

void main() {
    import core.simd: int4;
    import std.algorithm: sum;
    int4 x = [1, 2, 3, 4];
    int total = x.array[].sum;
}

--


More information about the Digitalmars-d-bugs mailing list