Am 10.12.2011 21:25, schrieb Walter Bright:
On 12/10/2011 11:03 AM, Mehrdad wrote:
So how are you supposed to implement opApply on a container (or e.g.
here, a
matrix)? Copy/paste the code for const- and non-const versions?

Internal to a function, inout behaves like 'const'. You won't be able to
modify the data. Therefore, if there is no inout in the return type, use
'const' in the parameter list instead.

The purpose of inout is to transmit the 'constness' of the function
argument type to the return type, using only one implementation of that
function. That requires the function to internally regard inout as const.

But what about:
void f(ref inout(int)* a, inout(int)* b) { a = b; }
This cant work with const because that would violate the const system. I think the rule should be that either the return type must be inout or at least one ref/out parameter.
Am I overlooking something?

Mafi

Reply via email to