Re: Get pointer or reference of an element in Array(struct)

2017-12-11 Thread Arun Chandrasekaran via Digitalmars-d-learn
On Saturday, 9 December 2017 at 19:26:26 UTC, David Nadlinger wrote: but "free" references don't exist in the language. To the point! Thanks!

Re: Get pointer or reference of an element in Array(struct)

2017-12-09 Thread Azi Hassan via Digitalmars-d-learn
On Saturday, 9 December 2017 at 06:46:27 UTC, Arun Chandrasekaran wrote: On Saturday, 9 December 2017 at 06:38:46 UTC, anonymous wrote: On Saturday, 9 December 2017 at 06:15:16 UTC, Arun Chandrasekaran wrote: Is there a way to get the pointer or reference of an element in Array(T)? [...]

Re: Get pointer or reference of an element in Array(struct)

2017-12-09 Thread David Nadlinger via Digitalmars-d-learn
On Saturday, 9 December 2017 at 06:46:27 UTC, Arun Chandrasekaran wrote: Thanks. Just curious why reference can't be obtained here. Saves nasty null checks in most places. D simply doesn't have a (C++-style) concept of references as part of the type. Arguments can be passed by reference - henc

Re: Get pointer or reference of an element in Array(struct)

2017-12-08 Thread Arun Chandrasekaran via Digitalmars-d-learn
On Saturday, 9 December 2017 at 06:38:46 UTC, anonymous wrote: On Saturday, 9 December 2017 at 06:15:16 UTC, Arun Chandrasekaran wrote: Is there a way to get the pointer or reference of an element in Array(T)? [...] auto d2 = gallery[0]; auto d2 = &gallery[0]; Thanks. Just curious why

Re: Get pointer or reference of an element in Array(struct)

2017-12-08 Thread anonymous via Digitalmars-d-learn
On Saturday, 9 December 2017 at 06:15:16 UTC, Arun Chandrasekaran wrote: Is there a way to get the pointer or reference of an element in Array(T)? [...] auto d2 = gallery[0]; auto d2 = &gallery[0];

Get pointer or reference of an element in Array(struct)

2017-12-08 Thread Arun Chandrasekaran via Digitalmars-d-learn
Is there a way to get the pointer or reference of an element in Array(T)? https://run.dlang.io/gist/70fd499afe8438d4877f57aec90c3091?compiler=dmd The assertion seems to fail below. Value copy is not is intended here. module test; void main() { struct Data { int id; }