Various C++ utility functions