Efficiently passing structs

bitwise via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun May 3 18:58:12 PDT 2015


If I have a large struct that needs to be passed around, like a 4x4 matrix  
for example, how do I do that efficiently in D?

In std.datetime, "in" is used for most struct parameters, but I'm confused  
by the docs for function parameter storage classes[1].

In C++, I would pass a large struct as (const&):
void foo(const Matrix4x4 &m);

Is "in" in D the same as passing by const& in C++? The documentation  
doesn't say anything about "in" being a reference, but it doesn't say that  
"out" parameters are references either, even though it's usage in the  
example clearly shows that it is.

Thanks,
   Bit

http://dlang.org/function.html#parameters


More information about the Digitalmars-d-learn mailing list