Better HN
top
new
best
ask
show
jobs
Log in
Sign up
Better HN
Comment
by
zach43
· 8y ago · 0 comments
Wouldn't you have a problem with reference cycles in C++ smart pointers? Not sure if they do anything special to prevent this.
Comments
[–]
nobugs
8y ago
std::unique_ptr<> won't allow you to have 'owning' reference cycles; neither 'owning' reference cycles are really necessary in real-world programs.
[–]
saagarjha
8y ago
std::weak_ptr is there for resolving reference cycles.
[–]
pdpi
8y ago
Which means you have to design around it. You can definitely run into problems with cyclical shared_ptr dependencies
[–]
saagarjha
8y ago
Well, you have to do this for every language that does reference counting.
[–]
pjmlp
8y ago
Either that, or have a cycle collector in addition to the normal reference counting optimizations.