3 ms·
Keeping the codebase clean is why I prefer that allocation errors throw an exception rather than returning NULL.
by mark-r 7y ago
Keeping the codebase clean is why I prefer that allocation errors throw an exception rather than returning NULL.
- cesarb 7y agoBut then you have to worry about exception safety on every code which might call an allocating function, making the code more complex. This is worse on C++ where even innocent-looking code could be allocating memory in the middle of an operation (for instance, by calling a copy constructor which allocates).