Finite state dictionaries in C++