Useful functions for C++