More on C++ stack arrays

Walter Bright newshound2 at digitalmars.com
Sun Oct 20 18:48:58 PDT 2013


On 10/20/2013 5:59 PM, Jonathan M Davis wrote:
> If that paradigm is frequent enough, it might be worth wrapping it in a
> struct. Then, you'd probably get something like
>
> StaticArray!(int, 10) tmp(n);
> int[] a = tmp[];
>
> which used T[10] if n was 10 or less and allocated T[] otherwise. The
> destructor could then deal with freeing the memory.

Sounds like a good idea - and it should fit in with Andrei's nascent allocator 
design.



More information about the Digitalmars-d mailing list