new T[size] vs .reserve
Era Scarecrow
rtcvb32 at yahoo.com
Sun Feb 3 12:11:15 PST 2013
On Sunday, 3 February 2013 at 13:22:53 UTC, bearophile wrote:
> The interface of alloca() is bug-prone. And it's not handy if
> you want to create a 2D or nD array on the stack :-) In
> bugzilla there is a preliminary request for better and less
> bug-prone VLAs for D.
Maybe. I barely have ever used alloca myself, but glancing over
the VLA's it seems iffy. If there's just one it's easy to
implement, however if there's several then the data would point
to a slice on the stack. I can see how it works in my head, but
with dynamic arrays, malloc & scope you can get a similar affect.
Hmmm... Maybe a possible use for a template instead?
More information about the Digitalmars-d-learn
mailing list