Will D 2.x have refrences
BLS
nanali at nospam-wanadoo.fr
Thu Oct 11 06:53:56 PDT 2007
Jari-Matti Mäkelä schrieb:
> BLS wrote:
>
>> I mean something comparable to :
>> //C++
>> int value = 100;
>> int & rIntRef = value;
>> if (rIntRef == 100)
>> // be ashured my val is 100
>> rIntref = 101
>> if (&rIntref == &value)
>> // Yes we have the same address
>>
>> (not parameter passing)
>> Bjoern
>
> void main() {
> int value = 100;
> alias value rIntRef;
>
> if (rIntRef == 100)
> rIntRef = 101;
>
> assert(value == 101);
> assert(&value == &rIntRef);
> }
>
> Alias parameters also work in functions wrapped inside templates.
Thanks Jari, I simply did not know about that feature. (ashamed)
Bjoern
More information about the Digitalmars-d
mailing list