Anybody have any idea on how to do shared operator overloads?

Ruby The Roobster rubytheroobster at yandex.com
Thu Jun 2 01:29:39 UTC 2022


On Thursday, 2 June 2022 at 01:00:57 UTC, Ali Çehreli wrote:
> On 6/1/22 17:36, Ruby The Roobster wrote:
> > A stripped down version of some code I have:
>
> Not much experience here but I made two changes:
>
> 1) Added 'shared':
>
> >          this(Complex!real num = Complex!real(0,0)) shared
> >          {
> >              this.num = num;
> >          }
> >          this(shared Complex!real num = cast(shared
> > Complex!real)Complex!real(0,0))
> >          {
> >              this.num.re = num.re;
> >              this.im.re = im.re;
>
> 2) Fixed apparent typos:
>
>   this.num.im = num.im;
>
> >          }
>
> I can't guarantee that correct functions are called. It just 
> compiles with 2.100.0. :)
>
> Ali

Yes, those were typos.  However, when making this post, I forgot 
to mark ```this(shared Complex!real num = cast(shared 
Complex!real)Complex!real(0,0))``` as shared.  The other 
constructor is not marked as shared in my code, considering as 
shared classes have all of their members marked as shared.


More information about the Digitalmars-d-learn mailing list