useful c++ helper functions and classes