const in functions
Salih Dincer
salihdb at hotmail.com
Mon Mar 13 15:17:56 UTC 2023
On Sunday, 12 March 2023 at 19:09:13 UTC, Ali Çehreli wrote:
> ---
In this case, using `ref` will increase performance while
reducing the number of copies. Would it be wise to use `const
ref` to protect the routine from ourselves or someone else? For
example:
```d
auto inConst(
//const
ref Int a, const ref Int b)
{
a.x += 1;
return Int(a.x + b.x);
}
struct Foo(T) {
T x;
alias x this;
this(T n) { x = n; }
}
alias Int = Foo!int;
```
SDB at 79
More information about the Digitalmars-d-learn
mailing list