out default argument of void

Caligo iteronvexor at gmail.com
Wed Jan 4 15:35:18 PST 2012


On Wed, Jan 4, 2012 at 4:40 PM, Jesse Phillips
<Jessekphillips+D at gmail.com> wrote:
>
> Out parameters are initialized. The declaration you want is:
>
> bool fun(double theta, A a = A.init, B b = B.init, C c = C.init){ /* ... */
> }
>

In my case A, B, and C are structs, so that works the way I wanted it. Nice!

It doesn't, however, work with primitive types:

void fun2(int a, out int b = int.init){ }
int a = 32;
fun2(a);  Error: constant 0 is not an lvalue

oh well.


More information about the Digitalmars-d-learn mailing list