Skip to content

staticArray and string #66

@fabienmica

Description

@fabienmica

staticArray does not compile when string with:

mir-core\source\mir\functional.d(57,12): Error: returning a escapes a reference to variadic parameter a

The code below compiles, removing the comment doesn't.

import mir.functional: staticArray;
import mir.ndslice;

auto resuF = mir.ndslice.cartesian([0,1,2], [0,1], [4,5,6]).flattened.map!staticArray;
writeln(resuF);
 
auto resuS = mir.ndslice.cartesian(["A", "B"], ["c","b"]).flattened;//.map!staticArray;
writeln(resuS);

Replacing current staticArray (in mir.functional) with code below works:

T[N] staticArray(T, size_t N)(T[N] a...)
   if (!is(T == string)) {
    return a;
}

T[N] staticArray(T, size_t N)(T[N] a...)
    if (is(T == string)) {        
        T[N] ret;
        static foreach(i; 0..a.length) ret[i] = a[i];
        return ret;
    } 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions