Your todo function should probably be std::unimplemented. You could also make it an uncaught exception, such as std::runtime_errorlogic_error. The best way to handle an out-of-memory error is to throw std::bad_alloc as the Standard Library does, or to allocate a smart object such as std::unique_ptr or std::vector that manages its own memory.