Storing "auto" types in classes

2010-07-02 Thread Rob Adelberg
I'm sure this has come up before, but I want to store something like an
std.array appender in a class.  All of the examples use auto for the type but
you can't put that in a class definition, so what do you put?

Example:
class packet{...}

class A {

   packet []  packetlist;
   appender!(packet) packappender;   // wrong format

   this () {
  packetlist = new packet[0];
  packappender = appender(&packetlist);
   }
   :
}

What's the format to store the appender in the class?


Dtnamic array memory allocation

2010-01-07 Thread Rob Adelberg
Does the dynamic array pre-allocate any memory?

I'm curious if the ~= on an array would be time sensitive. Would it make sense
to allocate memory myself and then reset the length?

class A
{
uint [] array;
:
  this()
  {
 array = new uint [10];
 array.length = 0;
  }
}