Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

staticArray and string #66

Open
fabienmica opened this issue Oct 4, 2022 · 2 comments
Open

staticArray and string #66

fabienmica opened this issue Oct 4, 2022 · 2 comments

Comments

@fabienmica
Copy link
Contributor

fabienmica commented Oct 4, 2022

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;
    } 
@9il
Copy link
Member

9il commented Oct 4, 2022

@fabienmica Could yo make MR with isDynamicArray!T instead of is(T == string)?

@fabienmica
Copy link
Contributor Author

ok will do

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants