Re: inout after function

2017-11-26 Thread Guillaume Piolat via Digitalmars-d-learn
On Saturday, 25 November 2017 at 21:51:41 UTC, Dave Jones wrote: What does the "inout" after front() do here... @property ref inout(T) front() inout { assert(_data.refCountedStore.isInitialized); return _data._payload[0]; } Cant seem to find an explanation in the docs or forums :(

Re: inout after function

2017-11-26 Thread Dave Jones via Digitalmars-d-learn
On Sunday, 26 November 2017 at 04:51:08 UTC, Adam D. Ruppe wrote: On Sunday, 26 November 2017 at 01:35:01 UTC, Dave Jones wrote: So it makes it a const/immutable/mutable method depending on whether the instance it is called on is const/immutable/mutable? On the outside, yes. So

Re: inout after function

2017-11-25 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 26 November 2017 at 01:35:01 UTC, Dave Jones wrote: So it makes it a const/immutable/mutable method depending on whether the instance it is called on is const/immutable/mutable? On the outside, yes. So @property ref inout(int) front() inout { return i++; }

Re: inout after function

2017-11-25 Thread Dave Jones via Digitalmars-d-learn
On Saturday, 25 November 2017 at 21:59:54 UTC, Ali Çehreli wrote: On 11/25/2017 01:51 PM, Dave Jones wrote: > What does the "inout" after front() do here... > > > @property ref inout(T) front() inout > { > assert(_data.refCountedStore.isInitialized); > return _data._payload[0]; > } > >

Re: inout after function

2017-11-25 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 25 November 2017 at 21:51:41 UTC, Dave Jones wrote: What does the "inout" after front() do here... Applies the `inout` modifier to the hidden `this` variable inside the function. https://dlang.org/spec/function.html#inout-functions It basically makes it const inside the

Re: inout after function

2017-11-25 Thread Ali Çehreli via Digitalmars-d-learn
On 11/25/2017 01:51 PM, Dave Jones wrote: > What does the "inout" after front() do here... > > > @property ref inout(T) front() inout > { > assert(_data.refCountedStore.isInitialized); > return _data._payload[0]; > } > > Cant seem to find an explanation in the docs or forums :( It's

inout after function

2017-11-25 Thread Dave Jones via Digitalmars-d-learn
What does the "inout" after front() do here... @property ref inout(T) front() inout { assert(_data.refCountedStore.isInitialized); return _data._payload[0]; } Cant seem to find an explanation in the docs or forums :(