inout and opApply
Shachar Shemesh via Digitalmars-d
digitalmars-d at puremagic.com
Thu Jun 23 23:08:48 PDT 2016
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
More information about the Digitalmars-d
mailing list