Skip to content

Sum doesn't work for const(Slice!T*) #454

@jmh530

Description

@jmh530

mir.math.sum doesn't work with slices where the container itself is const. So for instance, it fails with const(Slice!T*), but not const(Slice!(const(T)*)).

The error it gives here is pretty long, but my testing suggests that the source of the problem is the use of core.lifetime.move. isIterable is true and elementType will Unqual any type that should be getting fed through.

unittest { import mir.math.sum: sum; import mir.ndslice.slice: sliced; double[] x = [0.0, 1, 2]; auto y = x.sliced; assert(y.sum == 3); //no error auto z = y.toConst; assert(z.sum == 3); //no error const z2 = y; //assert(z2.sum == 3); //error for type: const(mir.ndslice.slice.mir_slice!(double*, 1uL, 2).mir_slice) const z3 = y.toConst; //assert(z3.sum == 3); //error for type: const(mir.ndslice.slice.mir_slice!(const(double)*, 1uL, 2).mir_slice) }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions