On Tuesday, 23 June 2015 at 11:03:10 UTC, Jonathan M Davis wrote:
Which does not generally work in D. It can in some cases, but const is so restrictive in D that you simply cannot use it just because you don't intend to mutate a variable. Too many types won't work with const, and many types _can't_ work with const. const has its uses, but you have to be careful with it, and in the general case, that means that you can't put it on function parameters just to indicate that the function argument is not going to mutated.

- Jonathan M Davis

Thus the solution cannot require const.

auto is worse because, if you later decide you need to add a template parameter then the meaning is changed and you get a _hidden_ performance issue.

Thus requiring neither auto nor const is the least evil of the above.

You could always use comments, or even dummy aliases to make the code self-documenting:

alias view(T...) = T;
void example(ref view!int i) {}

Reply via email to