On Thursday, 15 March 2018 at 12:00:08 UTC, Robert-D wrote:
I want the function to create a mutable copy from a const or a
imutable
Like this:
void main() {
const S s = S(["": ""]);
S b = s.dup();
}
How can i do that?
In that case, the problem is that you also have to .dup the aa:
S dup() const pure {
return S(aa.dup);
}
However, it seems aa.dup returns the wrong type - one would
expect V[K] for inout(V[K]), but it returns inout(V)[K], or
inout(string)[string], in your case. That's apparently a known
bug: https://issues.dlang.org/show_bug.cgi?id=14148.
The solution for now, then, is this:
S dup() const pure {
return S(cast(string[string])aa.dup);
}
--
Simen