Why can a T* be passed in register, but a unique_ptr cannot?
I'm watching Chandler Carruth's talk in CppCon 2019: There are no Zero-Cost Abstractions in it, he gives the example of how he was surprised by just how much overhead you incur by using an std::unique_ptr<int> over an int*; that segment starts about at time point 17:25. You can have a look at the compilation results (Godbolt.org) of his example pair-of-snippets - to witness that, indeed, it seems the compiler is not willing to pass the std::unique_ptr value - which in fact in the bottom line is just an address - inside a register, only on the stack. One of the points Mr. Carruth makes at aroun
0 upvotes
View original discussion ↗
Comments
Sign in or sign up to comment and upvote.
No comments yet.