C++ Template Turing Machine