Useful C++ code snippets