3 ms·
Who needs garbage collection when you have std::shared_ptr.
by clishem 10y ago
Who needs garbage collection when you have std::shared_ptr.
- lokedhs 10y agoProbably people who are having more complex data than a single tree. Exaggerated, I know, but it's not like your post was particularly nuanced.
- civility 10y ago> Probably people who are having more complex data than a single tree. Reference counting is safe with a DAG (not just a tree), but I get your point. For the times I've needed an arbitrary graph data structure, I used an adjacency matrix to store it.
- duneroadrunner 10y agostd::shared_ptr works, but fyi often there's a slightly better alternative. For cases where the target object is not shared between asynchronous threads, mse::TRefCountingPointer[1] is smaller/safer/faster/more scalable. For cases where the target is shared between threads (while being modified) mse::TAsyncSharedReadWriteAccessRequester[2] is safer. [1] shameless plug: https://github.com/duneroadrunner/SaferCPlusPlus#reference-counting-pointers https://github.com/duneroadrunner/SaferCPlusPlus#reference-c... [2] https://github.com/duneroadrunner/SaferCPlusPlus#asynchronously-shared-objects https://github.com/duneroadrunner/SaferCPlusPlus#asynchronou...