4 ms·
You're passing a shared pointer by value. That's two layers of misuse. Let alone writing out a constructor for basic types which the default one will handle. I
by Bancakes 4y ago
You're passing a shared pointer by value. That's two layers of misuse. Let alone writing out a constructor for basic types which the default one will handle.
I can't demonstrate it because godbolt is utterly broken on mobile, but passing unique_ptr reference is the clean way.
Importantly, you can just pass raw pointers or references around because adding objects does not semantically modify them or their ownership.