I am becoming more and more excited about C++0x these days. It would be interesting to see some elegant examples of the new power. What is your favorite sample that makes other C++ programmers smile?
For me it was the following one which I saw in Wikipedia, I just modified it little bit:
uniform_int_distribution<int> distribution(1, 6); mt19937 engine; auto dice = bind(distribution, engine); int random = dice(); // Generate a uniform integral variate between 1 and 6
The beautiful things about this code, is that it shows the new random number stuff in the enhanced
std library. The use of functional composition with
auto-inference is really powerful and eye pleasing. I am amazed how someone could write code at this level of abstraction, and in the same time the compiler has all the information to optimize this code greatly.