You could easily catch that within the method though. But in general I think throwing an exception on memory allocation failure is much better than the alternative, which is - in practice - assuming it succeeds and segfaulting.