On 07/10/2017 05:42 PM, drug wrote:
10.07.2017 17:57, ag0aep6g пишет:
[...]
The error message is: "cannot implicitly convert expression (f(& p)) of
type immutable(int)** to immutable(int**)".
[...]
I'm not sure I understand, but
```
immutable (T)** r = f(&p);
```
compiles. So compiler complains that indirections are mutable, but immutable ones are expected according to type of `r`

In itself, the error message makes sense. We can't usually convert from `immutable(int)**` to `immutable(int**)`.

We also can't usually convert from `int**` to `immutable(int**)`. But we can when the `int**` comes from a "pure factory function". And as far as I can see, it could/should also work when the pure factory function returns `immutable(int)**`.

For some context, I originally tried something like this:

----
struct S
{
    string str;
    int other_stuff;
}

void main()
{
    import std.algorithm: map;
    import std.array: array;
    S[] structs;
    immutable strs = structs.map!(s => s.str).array;
}
----

Reply via email to