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.
