Re: Propagating constness through function results

2017-09-17 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/17/17 5:37 PM, David Zhang wrote: Nevermind! I rediscovered the `inout`attribute. Correct, inout applied to the function is actually applying to the 'this' parameter. Same as const or immutable functions as well. Though if I may say so, I have no idea how `inout` is supposed to

Re: Propagating constness through function results

2017-09-17 Thread David Zhang via Digitalmars-d-learn
Nevermind! I rediscovered the `inout`attribute. Though if I may say so, I have no idea how `inout` is supposed to indicate "whatever the constness of a".

Re: Propagating constness through function results

2017-09-17 Thread David Zhang via Digitalmars-d-learn
On Sunday, 17 September 2017 at 21:18:08 UTC, David Zhang wrote: Hi, I have a class `Image`, and I have a function called `getSubImage(Rect bounds)`. What I can't figure out is how to get the result of `getSubImage()` to take on the constness of the backing image. ie. //The Image

Propagating constness through function results

2017-09-17 Thread David Zhang via Digitalmars-d-learn
Hi, I have a class `Image`, and I have a function called `getSubImage(Rect bounds)`. What I can't figure out is how to get the result of `getSubImage()` to take on the constness of the backing image. ie. //The Image class is really just a view over a buffer that's managed elsewhere