On 24/06/16 01:22, Steven Schveighoffer wrote:

Considering the possible use cases for something like this, I think we
are better off having this limitation than not being able to use opApply
with inout.

-Steve

I am not sure I followed the discussion correctly. If I did, however, it seems to me the following would also become impossible:

size_t numElements(T)(const ref T val) {
  size_t num;

  foreach(i; val) {
    num++;
  }

  return num;
}

If "val" being const means that the delegate passed to opApply must also be const, the meaning is that that delegate may not change "num", which seems, to me, unworkable.

All assuming I correctly understood your suggestion.

Shachar

Reply via email to