Struct beeing moved around

Jonathan M Davis jmdavisProg at gmx.com
Fri May 20 12:49:53 PDT 2011


On 2011-05-20 11:52, so wrote:
> On Fri, 20 May 2011 21:44:19 +0300, Jonathan M Davis <jmdavisProg at gmx.com>
> 
> wrote:
> > That wouldn't work with
> > 
> > A a(args, to, constructor);
> > 
> > Now, I personally never use that syntax and always use
> > 
> > auto a = A(args, to, constructor);
> > 
> > but you can't do the first form without a constructor, and even in the
> > second
> > form, you're making it clear that you're spefically constructing a value
> > of
> > that type as opposed to using a some random function which happens to
> > produce
> > that type. But ultimately, constructors are just special functions
> > anyway.
> > 
> > - Jonathan M Davis
> 
> Wait a minute, i thought "A a(args, to, constructor)" wasn't allowed in D.
> And "test t(5);" gives an error.

Hmm. I was sure that it was, but I just tried it, and it won't compile. I'm 
confused now. I never use that style though - even with no arguments to the 
constructor - so that the type's static opCall will be used instead of its 
init value if it has one. e.g.

auto a = A();

instead of

A a;

So, it's not something that I would ever have tried anyway. But I guess that 
it was either changed ot some point, or I misremembered about it being legal.

- Jonathan M Davis


More information about the Digitalmars-d mailing list