D2.0 Stack allocated classes

S. S at s.com
Fri Jun 29 16:35:21 PDT 2007


Per the memory management whitepaper, the following conditions are given for allocating a class on the stack instead of the heap.

    * are allocated as local symbols in a function
    * are allocated using new
    * use new with no argument
    * have the scope storage class

That covers every way I know how to allocate a class in D.  Maybe is poorly written, and I'm confused.  Lists like this are typically used to imply that ANY of the conditions being true would cause a stack allocation.  If that's not the case, just say:

"If the class is allocated as a local symbol in a function using new with no arguments and has the scope storage class, then it is allocated on the stack."

If I'm not confused, then how do you get something to be allocated on the heap?



More information about the Digitalmars-d mailing list