digitalmars.D.learn - Allocating classes on the stack
- Lionello Lunesu (31/31) Nov 24 2006 The following code works, but is it kosher?
The following code works, but is it kosher? #import std.c.stdlib, std.stdio; #template stackAllocator() { #T stackNew(T)(void* sp =alloca(T.classinfo.init.length) ) { #class A { #void main() { C:\Users\llunesu\Desktop>dmd -run stack.d { this newed ~this } (It's too bad I can't use "scope class A", since the stackNew is not allowed to return a scoped class) L.
Nov 24 2006