void init of out variables

Igor Shirkalin via Digitalmars-d digitalmars-d at puremagic.com
Fri Aug 18 23:23:10 PDT 2017


On Saturday, 19 August 2017 at 06:20:28 UTC, Nicholas Wilson 
wrote:
> I have a function that takes a large matrix as an out parameter.
> Is there a way to do `=void` for an out parameter like there is 
> for is for a plain declaration?
> enum M = 2600;
> void f() {
>     float[M] mean = void; // works as expected, mean is left 
> uninitialised
> }
>
> void g(out float[M][M] corr) // works but assigns twice
> {
>     corr[] = float.init; // compiler inserted
>
>     // assign to each value of corr
> }
>
> //Error: found ')' when expecting '.' following void
> void h(out float[M][M] corr = void)
> {
>
> }
>
> is there a way to not assign to out variables?

Try 'ref' instead of 'out'.


More information about the Digitalmars-d mailing list