On 2012-23-15 16:10, Simen Kjaeraas <simen.kja...@gmail.com> wrote:

On 2012-05-15 16:10, Namespace <rswhi...@googlemail.com> wrote:

How can I do this?

I have this code: http://dpaste.dzfl.pl/d9165502

And as you can see, the templated function 'receive2' take automatically dynamic arrays. But how can I tell the compiler, that this function takes (preferably) static arrays? My little "hack" function 'receive' take the type and the number of elements. So the compiler know: it's a static array. But is there no simpler trick to do this?
Maybe something like 'void receive(T)(static T vals) {'.

Nope. That's the way to do it.

No, wait, sorry. You don't need to specify those things when calling the
function. This works:

void bar(T, size_t n)(T[n] a) {}

void main(){
    int[3] a;
    bar(a);
}

--
Simen

Reply via email to