Do I have to pass parameters with ref explicitly?

max haughton maxhaton at gmail.com
Sun Apr 17 04:00:19 UTC 2022


On Sunday, 17 April 2022 at 03:00:28 UTC, Elfstone wrote:
> I'm reading some d-sources, and it looks like they pass big 
> structs by value.
> Such as:
>
>     Matrix4x4f opBinary(string op)(Matrix4x4f rhs) { ... }
>
> I came from a C++ background, and I would have written:
>
>     Matrix4x4f opBinary(string op)(const ref Matrix4x4f rhs) { 
> ... }
>
> I haven't found anything in the docs yet. Will the d-compiler 
> optimize them into virtually the same? Can someone give me a 
> reference?

It's the same as C++.


More information about the Digitalmars-d-learn mailing list