digitalmars.D.learn - How do you pass in a static array by reference?
- Enjoys Math (5/5) Feb 07 2016 I have several class members:
- Jakob Ovrum (10/15) Feb 07 2016 void foo(ref Arc[4] arr)
- Jakob Ovrum (8/27) Feb 07 2016 Alternatively you can take a slice of the fixed-length array:
I have several class members: Arc[4] arcs; Arc[4] arcs_2; and Id like to initialize them with the same function, so how do I "pass them in" by reference?
Feb 07 2016
On Monday, 8 February 2016 at 05:59:43 UTC, Enjoys Math wrote:I have several class members: Arc[4] arcs; Arc[4] arcs_2; and Id like to initialize them with the same function, so how do I "pass them in" by reference?void foo(ref Arc[4] arr) { … } The dimension can of course be templatized: void foo(size_t n)(ref Arc[n] arr) { … }
Feb 07 2016
On Monday, 8 February 2016 at 06:01:24 UTC, Jakob Ovrum wrote:On Monday, 8 February 2016 at 05:59:43 UTC, Enjoys Math wrote:Alternatively you can take a slice of the fixed-length array: void foo(Arc[] arr) { … } foo(arcs[]); foo(arcs_2[]);I have several class members: Arc[4] arcs; Arc[4] arcs_2; and Id like to initialize them with the same function, so how do I "pass them in" by reference?void foo(ref Arc[4] arr) { … } The dimension can of course be templatized: void foo(size_t n)(ref Arc[n] arr) { … }
Feb 07 2016