inout based on this reference?
Simen kjaeraas
simen.kjaras at gmail.com
Mon Aug 30 10:49:20 PDT 2010
Steven Schveighoffer <schveiguy at yahoo.com> wrote:
0123456789012345678901234567890123456789012345678901234567890123456789012
> 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.
So horribly broken that example does not work at all, or is that just me?
This is my code, verbatim:
//////////////////////////
module foo;
struct bar {
int n;
ref inout( int ) getN( ) inout {
return n;
}
}
void main( ) {
}
//////////////////////////
And it gives this message:
foo.d(5): Error: inout on return means inout must be on a parameter as
well for inout inout(int)()
--
Simen
More information about the Digitalmars-d-learn
mailing list