On Tue, 13 Oct 2009 07:30:11 -0400, bearophile
wrote:
Steven Schveighoffer:
A static variable is essentially a scoped global variable. I think it
will work if you make it static. I've used plenty of static variables
that are instances of the struct they are declared in.
It doesn't compi
Steven Schveighoffer:
> A static variable is essentially a scoped global variable. I think it
> will work if you make it static. I've used plenty of static variables
> that are instances of the struct they are declared in.
It doesn't compile with static variables too, you just need few seco
On Mon, 12 Oct 2009 15:38:07 -0400, bearophile
wrote:
Steven Schveighoffer:
It looks strange what you are doing. A Foo can have a memory pool of a
lot of Foo's? Do you mean to make the memory pool static?
Right and yes.
I think that might work.<
It works if I use a global variable.
Ary Borenszweig:
> I can see MemoryPool!(Foo) sizeof doesn't depend at all of T.sizeof
> because it just has a pointer.
Well, a dynamic array of pointers, but the situation is the same.
>But how do you suggest to fix the compiler to understand that?<
I don't know. I don't know enough about co
Steven Schveighoffer wrote:
On Mon, 12 Oct 2009 05:26:58 -0400, bearophile
wrote:
What's wrong with this code?
struct MemoryPool(T) {
alias T[100_000 / T.sizeof] Chunk;
Chunk*[] chunks;
}
struct Foo {
int x;
MemoryPool!(Foo) pool;
}
void main() {}
It prints "Error: struct pr
Steven Schveighoffer:
> It looks strange what you are doing. A Foo can have a memory pool of a
> lot of Foo's? Do you mean to make the memory pool static?
Right and yes.
>I think that might work.<
It works if I use a global variable. But I'd like to not used global variables
when possible
On Mon, 12 Oct 2009 05:26:58 -0400, bearophile
wrote:
What's wrong with this code?
struct MemoryPool(T) {
alias T[100_000 / T.sizeof] Chunk;
Chunk*[] chunks;
}
struct Foo {
int x;
MemoryPool!(Foo) pool;
}
void main() {}
It prints "Error: struct problem.Foo no size yet for fo
> T.sizeof must be 8 in all cases.
Ignore this line, please :-)
What's wrong with this code?
struct MemoryPool(T) {
alias T[100_000 / T.sizeof] Chunk;
Chunk*[] chunks;
}
struct Foo {
int x;
MemoryPool!(Foo) pool;
}
void main() {}
It prints "Error: struct problem.Foo no size yet for forward reference".
T.sizeof must be 8 in all cases.
So I ha