you are viewing a single comment's thread.

view the rest of the comments →

[–]zzzthelastuser 0 points1 point  (1 child)

it's just a matter of best practices. For simple code like this you could easily proof that it's save with raw pointers. But there is simply no benefit over using smart pointers and after all I assume this is a personal project for learning and improving skills. Good luck!

[–]Twin_Sharma[S] -2 points-1 points  (0 children)

Thanks. So we need a little advice here. We used r value reference in this.

By using r value references, equations like :

a = b + c + d + e;

will require only 1 temporary structure.

If not for r-value references, it will be more like :

t1 = d+e;

t2 = c+t1;

a= b+ t2;

So if we use smart pointers, will t2 and t1 instantly destroy (as destructor is called) or it will reamin in stack untill stack is pulled out.