The problem looks simple enough, basically I have a sequence of sequences, something like:
typedef mpl::vector<
mpl::vector<mpl::_1, mpl::_2>,
mpl::vector<mpl::_1, mpl::_2, mpl::_3>,
mpl::vector<mpl::_2, mpl::_1>,
mpl::vector<mpl::_2, mpl::_2>,
mpl::vector<mpl::_2, mpl::_2, mpl::_3>
> seq;
What I would like to do is to transform this to a trie, the end result being something like:
mpl::map<
mpl::pair<mpl::_1,
mpl::map<
mpl::pair<mpl::_2,
mpl::map<
mpl::pair<TERMINAL, T>,
mpl::pair<mpl::_3,
mpl::map<
mpl::pair<TERMINAL, T>
>
>
>
>
>
>
mpl::pair<mpl::_2,
mpl::map<
mpl::pair<mpl::_1,
mpl::map<
mpl::pair<TERMINAL, T>
>
>,
mpl::pair<mpl::_2,
mpl::map<
mpl::pair<TERMINAL, T>,
mpl::pair<mpl::_3,
mpl::map<
mpl::pair<TERMINAL, T>
>
>
>
>
>
>
>
So, the question is, is this possible (I’m thinking it’s not)? If it is possible, which dark spells have I missed?
EDIT: In case the above transformation from sequence of sequences to a trie is not clear, let me see if I can state it in plain English (often more difficult.) Basically each sequence within the main sequence is composed of some types (_1, _2 etc.) The transformed version is trie where common prefixes are collapsed. May be the attached picture helps..

EDIT2: Thanks to @Yakk, hopefully now the question is clearer…
There you go:
insertInTrie_implis a recursive metafunction that inserts a sequence into an existing trie, using iterators.insertInTrieaccepts a sequence an callsinsertInTrie_impl.constructTrieappliesinsertInTrieto all sequences in the given sequence, starting with an empty trie.In pseudo-code, this reads as follow:
Finally, a sample use: