auto ref function parameters in a free function
Vlad Levenfeld via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sun Aug 3 14:24:02 PDT 2014
On Sunday, 3 August 2014 at 20:10:39 UTC, Martijn Pot wrote:
> What is the benefit of 'auto ref' over 'in' as you are changing
> a nor b?
Because
less_than (T)(T a, T b)
(or in, or const T) will copy a and b on their way into the
function. Usually this is ok but certain data structures I use
are not intended to be copied, or they are just very large or
have very elaborate constructors that take up time and resources,
or something.
I don't know if inlining would solve this or not but as far as I
know there is no way to rely on inlining currently.
More information about the Digitalmars-d-learn
mailing list