On 10/20/2013 12:15 PM, David Nadlinger wrote:
I'm not particularly enamored with the compiler inserting silent copying to
the heap - D programmers tend to not like such things.

Well, this is exactly what happens with closures, so one could argue that there
is precedent.

Not at all. The closure code does not *copy* the data to the heap. It is allocated on the heap to start with.


I also find this pattern to be very useful. The LLVM support libraries even
package it up into a nice llvm::SmallVector<T, n> template that allocates space
for n elements inside the object, falling back to heap allocation only if that
threshold has been exceeded (a tunable small string optimization, if you want).

Nice!

Reply via email to