what means... auto ref Args args?

Moritz Maxeiner moritz at ucworks.org
Wed Oct 18 22:16:32 UTC 2017


On Wednesday, 18 October 2017 at 21:38:41 UTC, Dave Jones wrote:
> Poking around in the source code for emplace and I noticed...
>
> T* emplace(T, Args...)(T* chunk, auto ref Args args)
>
> what does the "auto ref" do in this situiation? Cant seem to 
> find any explanation in the docs.

It means that any argument (that is an element of args) will be 
passed by reference if and only if it's an lvalue (has a memory 
address that can be taken) (it'll be passed by value otherwise).

https://dlang.org/spec/template.html#auto-ref-parameters


More information about the Digitalmars-d mailing list