[Issue 12799] Forward reference to nested enum with struct.sizeof
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Sun May 25 00:51:23 PDT 2014
https://issues.dlang.org/show_bug.cgi?id=12799
--- Comment #1 from Sobirari Muhomori <dfj1esp02 at sneakemail.com> ---
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.
--
More information about the Digitalmars-d-bugs
mailing list