Auto recursive function

Razvan Nitu via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Jan 11 11:54:48 PST 2017


On Wednesday, 11 January 2017 at 19:30:05 UTC, Stefan Koch wrote:
> On Wednesday, 11 January 2017 at 19:23:10 UTC, Razvan Nitu 
> wrote:
>> Hi,
>>
>> I am currently trying to create a function 
>> makeMultidimensionalArray which allocates memory for a 
>> multidimensional array. It is very similar with [1],
>> the difference being that it is uninitialized. Here is the 
>> code:
>>
>> [...]
>
> I believe you should not do this with recursion.
> Because that'll instantiate the template multiple times with 
> different types.
> What is wrong with using ndslice here ?

Maybe you want to allocate memory for more complex data 
structures;
Using the function I am implementing, you will have the 
multidimensional
array initialized with the default values; you don't have to pass 
a slice
from which the initialization data is taken.


More information about the Digitalmars-d-learn mailing list