Duplicating multidimensional array

Joseph Rushton Wakeling joseph.wakeling at webdrake.net
Thu May 30 15:02:53 PDT 2013


On 05/30/2013 09:36 AM, Ali Çehreli wrote:
> What do you think about the following recursive template solution? I have tested
> it only with arrays of int. :/

Very impressed -- I would never have thought of that trick with the second
template parameter.  It's really nice to see these kinds of example, as it's
starting to bring to life the concepts of generic programming _as programming_,
not just simple templating of functions or classes.

I tried out the code with double-arrays of tuples, which is my use-case and
which works.  I guess it might fall over with complex structs or classes,
though. :-\

What do you reckon the impact of this will be performance-wise?  I'll try it out
of course, but what with all the array concatenations etc. I'm worried about
whether it might leak memory if repeated many times, and whether there might be
some other better way to copy all the values from one multidimensional array to
another.


More information about the Digitalmars-d-learn mailing list