Once problem solved in C++11

Here's a solution to the problem using many new features of C++11, almost all of which I wish I could forget now. :)