Stop function parameters from being copied.

Simen kjaeraas simen.kjaras at gmail.com
Thu Oct 7 08:11:45 PDT 2010


Benjamin Thaut <code at benjamin-thaut.de> wrote:

> If I want to tell the compiler that a certain function argument should  
> not be
> copied (say a large struct, or a array) which is the right way to do?
>
> arrays:
> 1. function foo(in float[] bar) { ... }
> 2. function foo(ref const(float[]) bar) { ... }
> 3. something else

For arrays, only the pointer and length are passed by value, the data
is passed by reference (said pointer).


> structs:
> 1. function foo(in largestruct bar) { ... }
> 2. function foo(ref const(largestruct) bar) { ... }
> 3. something else

#2.

-- 
Simen


More information about the Digitalmars-d-learn mailing list