Re: Function with static array as parameter

2017-07-13 Thread Miguel L via Digitalmars-d-learn
Thanks for your help.

Re: Function with static array as parameter

2017-07-12 Thread Nicholas Wilson via Digitalmars-d-learn
On Wednesday, 12 July 2017 at 12:20:11 UTC, Miguel L wrote: What is the best way in D to create a function that receives a static array of any length? Do know that static arrays are passed by value in D, so passing a static array of a million elements will copy them... There are two

Re: Function with static array as parameter

2017-07-12 Thread Rene Zwanenburg via Digitalmars-d-learn
On Wednesday, 12 July 2017 at 12:57:19 UTC, Rene Zwanenburg wrote: On Wednesday, 12 July 2017 at 12:20:11 UTC, Miguel L wrote: What is the best way in D to create a function that receives a static array of any length? Templatize the array length: void foo(size_t length)(int[length] arr) { }

Re: Function with static array as parameter

2017-07-12 Thread Biotronic via Digitalmars-d-learn
On Wednesday, 12 July 2017 at 12:20:11 UTC, Miguel L wrote: What is the best way in D to create a function that receives a static array of any length? You will need to use templates: void foo(size_t N)(int[N] arr) { } -- Biotronic

Re: Function with static array as parameter

2017-07-12 Thread Rene Zwanenburg via Digitalmars-d-learn
On Wednesday, 12 July 2017 at 12:20:11 UTC, Miguel L wrote: What is the best way in D to create a function that receives a static array of any length? Templatize the array length: void foo(size_t length)(int[length] arr) { }

Function with static array as parameter

2017-07-12 Thread Miguel L via Digitalmars-d-learn
What is the best way in D to create a function that receives a static array of any length?