4 ms·
> these types of data structures are not possible in C++ as they are in other languages, due to lack of GC or tail recursion[0] The link doesn't really explain
by vanderZwan 11y ago
> these types of data structures are not possible in C++ as they are in other languages, due to lack of GC or tail recursion[0]
The link doesn't really explain why though. I mean, I'm willing to believe this is true until proven otherwise - it's safe to assume Milewski knows what he's talking about - but I'd love to see a proper explanation.
- sonyandy 11y agoIt is in fact incorrect. The incorrect assumption is nested structure implies nested destructor calls. This can be avoided by ensuring each node in the structure does not destroy the next node_ptr (explicitly or more likely implicitly). Instead, the destruction has to happen more manually (internally to the overall data structure - not by the user). If the structure only recurses on one child, it can be performed as a loop.