enum - auto
so
so at so.so
Mon Nov 14 16:59:39 PST 2011
Thanks Simen!
On Mon, 14 Nov 2011 12:33:26 +0200, Simen Kjærås <simen.kjaras at gmail.com>
wrote:
>> Another issue, auto.
>> I was thinking that it works like C++0x auto.
>> Now i realize they are not that alike. Can anyone show me the D
>> equivalent of the code below?
>>
>> struct test {
>> int a;
>> };
>>
>> void main() {
>> test tmp;
>> auto& a = tmp.a;
>> }
>
> That would be a reference to an int, right? No such thing in D, except
> for
> function parameters. What you would do instead is get a pointer:
>
> struct test {
> int a;
> }
>
> void main() {
> test tmp;
> auto a = &tmp.a;
> }
I was at least expecting "[const ref/ref] auto a = tmp.a;" would work.
I don't see why it won't (anyone knows if it was by design or just the
matter of implementation?), i think it is quite important.
More information about the Digitalmars-d
mailing list