Collections question

Tobias Pankrath via Digitalmars-d digitalmars-d at puremagic.com
Mon Nov 30 08:21:09 PST 2015


On Monday, 30 November 2015 at 16:06:43 UTC, Steven Schveighoffer 
wrote:
> MyCollection!(int) c1;
> auto c2 = c1;
> c1 ~= 1;
>
> assert(c2.contains(1)); // pass? fail?
>
> BTW, I third Jonathan's and Timon's suggestion -- go with an 
> external factory function. Use IFTI to its fullest!
>
> -Steve

That should throw, because you're using an uninitialised 
reference (c1). It's the equivalent to:

Class C { .. }

C c1;
C c2 = c1;
c1.foo(); // call via nullptr

Or it needs to pass, but that's probably not worth it.


More information about the Digitalmars-d mailing list