I try to make a templated Trie structure. It represents tree in internal private struct Node, which contains TElem, bool which indicates that this particular node is a terminal and a vector of children:
template<typename TElem>
class Trie
{
// ...
private:
struct Node
{
TElem elem;
bool isTerminal;
std::vector<std::shared_ptr<Node>> children;
};
Node root_;
};
Now I’d like to make another template parameter that would make possible to select another underling container, e.g. list. How can it be done?
With template template parameters (untested code, but the general idea should be OK):
then