Reconstruct vals in C++