Collections question
Adam D. Ruppe via Digitalmars-d
digitalmars-d at puremagic.com
Fri Nov 27 12:25:10 PST 2015
On Friday, 27 November 2015 at 20:14:21 UTC, Andrei Alexandrescu
wrote:
> 1. Factory function:
This is my preference for zero arg at least because the opCall
thing is commonly misunderstood and confused with C++ default
construction and we don't need to encourage that.
> static MyCollection opCall(U...)(auto ref U args);
> auto c1 = MyCollection!(int)(1, 2, 3);
That syntax is the same as constructors... if that's what you
want it to look like, we ought to actually use a constructor for
all but the zero-argument ones which I'd use a static named
function for (perhaps .make or perhaps .makeEmpty too)
But the opCall in cases where it conflicts with constructors
ought to be discouraged.
More information about the Digitalmars-d
mailing list