struct A
{
enum C=A.sizeof;
enum D=C; //Error: forward reference of variable C
int a;
}
Comment #1 by dfj1esp02 — 2014-05-25T07:51:23Z
I first wanted to implement a variable-sized struct this way.
struct Region
{
enum fullSize=128, head=Region.sizeof/size_t.sizeof;
enum capacity=fullSize-head;
Region* prev;
int count;
void*[] allocations()
{
return all[0..count];
}
void put(void* data)
{
assert(count<capacity);
all[count]=data;
count++;
}
void*[] all(void* data)
{
void* b=cast(void**)&this+head;
return b[0..capacity];
}
}
Well, it's not really variable-sized, so I just declared a fixed-sized array in it.
Comment #2 by dfj1esp02 — 2014-05-30T17:31:25Z
Though a big fixed-sized array in a struct creates a big init value.