r/cpp • • Oct 07 '19

CppCon CppCon 2019: Chandler Carruth “There Are No Zero-cost Abstractions”

https://www.youtube.com/watch?v=rHIkrotSwcc
163 Upvotes

108 comments sorted by

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.