|
-
September 18th, 2011, 03:19 AM
#6
Re: Garbage Collection library C++
 Originally Posted by nuzzle
But if you have a Java background there's a limitation you should know about. Smart pointers cannot handle circular chains. If an object holds a smart pointer to an object this object may not hold a smart pointer back, not directly nor indirectly.
regarding reference counted smart pointers, this issue can be solved by using weak_ptr in conjunction with shared_ptr, so the claim that "Smart pointers cannot handle circular chains" is a bit too strong; moreover, there's also unique_ptr which forbids circular references from the beginning ( note that the OP speaks of "object pointers in vector array", so, he doesn't necessarily need a shared reference semantics ... )
anyway, I agree that a liberal use of shared_ptr as a blind replacement of object pointers/references is the wrong thing to do, although I cannot imagine a different reason for this to be assumed other then coming from a Java background ...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|