inout based on this reference?

Steven Schveighoffer schveiguy at yahoo.com
Mon Aug 30 06:09:04 PDT 2010


On Mon, 30 Aug 2010 09:08:11 -0400, Steven Schveighoffer  
<schveiguy at yahoo.com> wrote:

> On Sun, 29 Aug 2010 17:36:24 -0400, Simen kjaeraas  
> <simen.kjaras at gmail.com> wrote:
>
>> Is it possible to make a function return dependent upon the constancy  
>> of the this reference?
>>
>> i.e. this:
>>
>> struct foo {
>>     int n;
>>     inout( ref int ) getn( ) inout {
>>         return n;
>>     }
>> }
>
> Yes.  That is the bread-and-butter usage for inout.
>
> Although inout is currently horribly broken.

I should point out, the function sig should be:

ref inout(int) getn() inout

inout is a type modifier, ref is a storage class.

-Steve


More information about the Digitalmars-d-learn mailing list