Storage Class "in" D

When using the in storage class in D, the data is immutable for your function. Is it also passed in the data by reference, and not by value? I noticed that in ref not valid.

If in does not transmit data by reference, is there a way to get data by reference, but do you have a guarantee that the data will not be changed?

+6
source share
2 answers

in parameters are not passed by reference .

As far as I can tell from the documentation , in is just a shortcut to const scope . I do not see the possibility of emulating ref in parameters, since ref scope is illegal. As BCS said, you can use ref const if you don't need the scope storage class.

+7
source

I have not tested, but I think that ref const should work.

+2
source

Source: https://habr.com/ru/post/910935/


All Articles