Comment

Comment by gavinray

I meant something more like this (although this doesn't QUITE compile, but it's close I think):

    static ubyte* [n*2] requires_ptr_twice_as_large_as_input(n : uint)
    (
        ubyte*[n] input,
        ubyte*[n*2] output,
    ) {
        output[0..n] = input[0..n];
        output[n..2*n] = input[0..n];
        return output;
    }

    void main()
    {
        ubyte[10] input = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
        ubyte[20] output = new ubyte[20];
        requires_ptr_twice_as_large_as_input!(10)(&input, &output);
    }
parent gavinray 3 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton