Incorporating D
mist
none at none.none
Fri Jan 25 14:27:59 PST 2013
On Friday, 25 January 2013 at 22:22:44 UTC, Szymon wrote:
> So structs in D are always passed by-value? That is
> unfortunate...
>
No, that is what he speaks about:
--------
struct SomeStruct
{
int a, b;
}
void f1(ref SomeStruct input) { }
void f2(const ref SomeStruct input) { }
void main()
{
SomeStruct a;
f1(a); // fine
f2(a); // fine
// f1(SomeStruct(0,0)); // invalid, predictable
// f2(SomeStruct(0,0)); // invalid, surprise to C++ guys
}
--------
More information about the Digitalmars-d
mailing list