Re: Odd Associative Array Reference Behavior

2016-02-10 Thread Matt Elkins via Digitalmars-d-learn
On Thursday, 11 February 2016 at 03:47:09 UTC, Steven Schveighoffer wrote: Misunderstanding. An AA under the hood is simply a pointer. Initialized to null. When you pass it around, you are passing a pointer. AA assign checks for null and allocates a new AA impl to hold the data. But this does

Re: Odd Associative Array Reference Behavior

2016-02-10 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/10/16 10:10 PM, Matt Elkins wrote: Consider the following definition of Foo and an accompanying unittest: [code] struct Foo { @property int[int] aa() {return m_aa;} @property ref int[int] aaRef() {return m_aa;} int[int] m_aa; } unittest { Foo foo; assert(5 !in foo.

Odd Associative Array Reference Behavior

2016-02-10 Thread Matt Elkins via Digitalmars-d-learn
Consider the following definition of Foo and an accompanying unittest: [code] struct Foo { @property int[int] aa() {return m_aa;} @property ref int[int] aaRef() {return m_aa;} int[int] m_aa; } unittest { Foo foo; assert(5 !in foo.m_aa); // Sanity-check to start off foo.a