struct A
{
private int[] a;
this(int[] b){a=b;}
int[] c(){ return a; }
@disable void opAssign();
}
struct B
{
A a;
this(int){ a=new int[5]; }
int[] b(){ return a.c; }
void f(){ a=new int[5]; }
}
On Wednesday, 7 April 2021 at 12:28:25 UTC, tcak wrote:
@property auto b(){ return a.ptr; } // this is a
possibility, but results with overhead of calling. Also, b is
not an array anymore, just int*.
Why are you returning a.ptr instead of just a?
If you return just a, it works fine for w
In javascript, with "const" keyword, you assign an object to a
variable. Later, you cannot assign anything else to that
variable, but content of it still can be changed. No matter by
using "immutable" or "const", I cannot imitate that. Is there a
way to do this without an overhead (like calling