Passing structs to functions

H. S. Teoh via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Jul 2 12:20:54 PDT 2016


On Sat, Jul 02, 2016 at 06:47:31PM +0000, phant0m via Digitalmars-d-learn wrote:
> On Saturday, 2 July 2016 at 18:43:51 UTC, ketmar wrote:
> > void boo() (in auto ref MyStruct s) { ... }
> > 
> > this will accept both lvalues and rvalues, and will avoid copying if
> > it can.
> 
> Thank you! Could you please explain what does "auto" in this context
> mean?

It's actually "auto ref", which roughly means "automatically decide
whether it's more efficient to pass by value or pass by ref". The
compiler will decide whether or not to pass by ref.


T

-- 
Life is too short to run proprietary software. -- Bdale Garbee


More information about the Digitalmars-d-learn mailing list