Better HN
top
new
best
ask
show
jobs
Log in
Sign up
Better HN
Comment
by
int_19h
· 10y ago · 0 comments
Not all smart pointers are reference counting - unique_ptr is not, and it has zero overhead compared to a raw pointer. Sometimes you just need to heap allocate, or, say, shove a bunch of objects of different derived types in a same container.
Comments
[–]
Iv
10y ago
Yes sorry, I conflated smart pointers and shared_ptr. I rarely use the other kinds of smart pointers.
[–]
hellofunk
10y ago
In fact, in my tests, unique_ptr with make_unique was faster than a raw pointer with new.