On Sunday, 13 March 2016 at 20:10:57 UTC, Basile B. wrote:
Unless the result is explicitly cast later it can't me modified.import std.stdio, std.container.array; struct Foo { private Array!int arr; ref const(Array!int) view() { return arr; } } void main(string[] args) { Foo foo; auto a = foo.view.dup; }
...and any attempt will produce an error, like in my sample:Error: mutable method std.container.array.Array!int.Array.dup is not callable using a const object