Appending static arrays

ag0aep6g via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Jul 17 10:46:42 PDT 2017


On 07/17/2017 07:38 PM, Nordlöw wrote:
> I'm want to define a specialization of `append()` that takes only static 
> arrays as inputs and returns a static array being the sum of the lengths 
> of the inputs.
> 
> Have anybody already implemented this?
> 
> If not, I'm specifically interested in how to most conveniently infer 
> the length (as an enum) of the returned static array from the `.length`s 
> of inputs (which of course must be enum-values too).

Like so?

int[n + m] append(size_t n, size_t m)(int[n] a, int[m] b)
{
     int[n + m] result = a ~ b;
     return result;
}


More information about the Digitalmars-d-learn mailing list