Is `shared_ptr` just used for convenience? I think `unique_ptr` would be excellent for this tree structure.
It's not too bad to traverse the tree using non-owning raw pointers.
It's not too bad to traverse the tree using non-owning raw pointers.
Edit: on second thought, having a class contain a container of itself actually isn't allowed (though you would think it would be in cases like this).
Edit again: apparently it depends on the container. unordered_map does not allow instantiation with an incomplete type, but other containers do (e.g. vector or map).
struct example {
std::vector<example> xs;
};