You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Constructors don't receive this as the first argument #674
copy/move constructors and assignments introduce calls that C++ does not have:
implS{pubfncopy_from(o:Ptr<S>) -> Self{let __this:Counted = Self{
...// It constructs a fake __this that might have side effects};
...body of copy ctor ...
__this
}}implCloneforS{fnclone(&self) -> Self{// builds a fake argument for copy_from that might have side effects let __src:Value<S> = Rc::new(RefCell::new(S{ ...}));S::copy_from(__src.as_pointer())// drops the fake __src and the fields inside it}}
For 1, the solution is to build the storage before calling the constructor:
implS{pubfnnew(this:Ptr<Self>){
this.a = 1;
this.b = 2;}}let s:Value<S> = Rc::new(RefCell::new(/* uninitialized storage of S */));S::new(s.as_pointer());
For 2, the solution is to explicitly pass this to the copy ctor and stop using the Clone trait:
implSforCopyConstructible{pubfncopy_from(this:Ptr<S>,o:Ptr<S>){
...body of copy ctor ...
}}
Activity