On Tuesday, 7 May 2013 at 11:49:07 UTC, evilrat wrote:
On Tuesday, 7 May 2013 at 10:58:42 UTC, John Colvin wrote:
...
int a[];
please don't use C style declarations, D style is "type
followed by id":
int[] a;
woops, just copied it from the original post.
You could allocate space inside a class itself with something
like this:
class Base {
int[] slice;
}
template Derived(size_t N) {
class Derived : Base {
int[N] array;
this() {
slice = array;
}
}
}
Base b = new Derived!32();
A bit pointless thoug
On Tuesday, 7 May 2013 at 10:29:44 UTC, Namal wrote:
Hello,
I am new to D. According to that power of 2 rule I want to
reserve 2 sized chunks to my array, But how do I do that in a
struct?
You can set some kind of statically allocated array size:
struct S
{
int[] a;
this(size_
On Tue, 07 May 2013 06:29:43 -0400, Namal wrote:
Hello,
I am new to D. According to that power of 2 rule I want to
reserve 2 sized chunks to my array, But how do I do that in a
struct? Say:
struct Stack(int){
int a[];
}
Where do I put that a.reserve(2);
Because right after the declarati
On Tuesday, 7 May 2013 at 10:58:42 UTC, John Colvin wrote:
...
int a[];
please don't use C style declarations, D style is "type followed
by id":
int[] a;
On Tuesday, 7 May 2013 at 10:29:44 UTC, Namal wrote:
Hello,
I am new to D. According to that power of 2 rule I want to
reserve 2 sized chunks to my array, But how do I do that in a
struct? Say:
struct Stack(int){
int a[];
}
"2 sized chunks"?
Perhaps you want something like this:
struct