Nice C++ tricks for solving problem elegantly