On 11/27/2015 09:14 PM, Andrei Alexandrescu wrote:
There's this oddity of built-in hash tables: a reference to a non-empty
hash table can be copied and then both references refer to the same hash
table object. However, if the hash table is null, copying the reference
won't track the same object later on.

Fast-forward to general collections. If we want to support things like
reference containers, clearly that oddity must be addressed. There are
two typical approaches:

1. Factory function:
...

2. The opCall trick:
...


3. (Non-internal) factory function:

auto c1 = myCollection(1,2,3);
auto c2 = myCollection!int();
auto c3 = c2; // refers to the same collection as c2

Reply via email to