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@79

Reply via email to