Keeping a mutable reference to a struct with immutable members

Basile B. via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun May 29 12:52:37 PDT 2016


On Sunday, 29 May 2016 at 19:09:13 UTC, pineapple wrote:
> On Sunday, 29 May 2016 at 18:52:36 UTC, pineapple wrote:
>> What's the best way to handle something like this?
>
> Well I did get something to work but it's ugly and I refuse to 
> believe there isn't a better way to handle this.
>
> Where `Range` is an alias to a struct with an immutable member, 
> and `this.source` is the attribute that I need to be able to 
> re-assign to a locally scoped return value:
>
>     this.source = cast(Range*) newptr;

Do yo have a simple, concise runnable example to show ?


More information about the Digitalmars-d-learn mailing list