Struct Postblit Void Initialization

Moritz Maxeiner via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Jul 30 12:38:26 PDT 2017


On Sunday, 30 July 2017 at 19:22:07 UTC, Jiyan wrote:
> Hey,
> just wanted to know whether something like this would be 
> possible sowmehow:
>
> struct S
> {
> int m;
> int n;
> this(this)
> {
> m = void;
> n = n;
> }
> }
>
> So not the whole struct is moved everytime f.e. a function is 
> called, but only n has to be "filled"

I'll assume you mean copying (as per the title) not moving 
(because moving doesn't make sense to me in this context); use a 
dedicated method:

struct S
{
     int m, n;
     S sparseDup()
     {
         S obj;
         obj.n = n;
         return obj;
     }
}


More information about the Digitalmars-d-learn mailing list