3 ms·
Interesting! So, for clarity, a `std::unique_ptr` is ordinarily the same size as a raw pointer... unless you give it a custom allocator or deleter (since it ha
by shrimp_emoji 4y ago
Interesting!
So, for clarity, a `std::unique_ptr` is ordinarily the same size as a raw pointer... unless you give it a custom allocator or deleter (since it has to set aside more memory to store those functions).
BUT, using the (pretty over my head as I tried to read the code snippets on my phone :p) empty base optimization, the unique pointers seem able to store those functions at no extra cost.
- coralkashri 4y agoWell, this article was written using a phone, so it might be possible to read it using one :P And yes, it's completely true for cases that your custom deleter (pay attention that there is no custom allocator in std::unique_ptr, but it also true to allocators in other structures) doesn't contain any data members :) And thanks!