3 ms·
> See also this answer: > https://stackoverflow.com/a/48046118/1593077 https://stackoverflow.com/a/48046118/1593077 > to the question of why C++ doesn't have a
by pebal 4y ago
> See also this answer:
> https://stackoverflow.com/a/48046118/1593077 https://stackoverflow.com/a/48046118/1593077
> to the question of why C++ doesn't have a garbage collector.
The shared_ptr is an optional garbage collection based on reference counting. Slow, leaky, deterministic (that's an advantage and a disadvantage). C++ needs optional garbage collection if needs shared_ptr.
- pjmlp 4y agoC++11 introduced APIs for optional GC and since no one has ever fully provided one, it is going away on C++23. The way C++/CLI, C++/CX and Unreal C++ work isn't based on those APIs (naturally, given their domain), and are even used on the C++23 motivation paper as why those GC APIs should be removed.
- pebal 4y agoThe hazard pointer is basically a proposal to implement GC to solve one implementing problem in C++26.