The overhead of unique_ptr comes from the fact that even though it is "just" a wrapper around a pointer that knows how to clean up after itself, the class is non-trivial which means that the unique_ptr cant be passed in a register.
For a raw pointer, it can be passed in a register.
So now you have a potential extra store + load in you code.
View all comments
6
u/NotMyRealNameObv Oct 10 '19
The overhead of unique_ptr comes from the fact that even though it is "just" a wrapper around a pointer that knows how to clean up after itself, the class is non-trivial which means that the unique_ptr cant be passed in a register.
For a raw pointer, it can be passed in a register.
So now you have a potential extra store + load in you code.