Is it possible to "overload" based on visibility?
60rntogo at gmail.com
Fri Sep 25 15:13:17 UTC 2020
On Friday, 25 September 2020 at 14:21:59 UTC, Steven
> in does not mean "take by reference", it means "scope const"
I'm not sure that I really understand scope, but I read
https://dlang.org/spec/function.html#param-storage as saying "in
means take by value or reference depending on what is better
optimized". Is that not what we want here?
> It depends on if you want to return a copy. If you want to
> return a reference if the source is a reference, use auto ref
> on the return as well. But if you still want to protect the
> internal data, it would have to be const.
Right, again I'm wondering if there is a way of saying "just
figure out if it's more optimal to return by value or const
More information about the Digitalmars-d-learn