www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 12869] New: std.algorithm.sum for core.simd too

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 puremagic.com
          Reporter: bearophile_hugs 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;
}

--
Jun 06 2014