Add a compile-time C++ solution to problem 2