On 1/8/15 12:15 AM, Meta wrote:
On Wednesday, 7 January 2015 at 23:27:19 UTC, anonymous wrote:
Don't do this without `dup`ing. Quoting the documentation:

Oh, whoops. I thought those special variadic args were always allocated
on the heap.

Nope,

Which makes it annoying, what if the argument IS passed on the heap?

Fortunately, there is a solution (one I use in dcollections):

foo(T[] x...)
foo(T[] x)

Can be overloaded. If you ever pass in parameters one at a time, the first is called, and x is guaranteed to be on the stack.

The second is called with an actual array only, you are able to not 'dup', and just warn people that x will NOT be dup'd in that case.

-Steve

Reply via email to