Originally Posted by
CornedBee
1. auto_ptr is used to ensure that the memory is freed. It has nothing at all to do with allocation. So yes, whether or not you use it, the new operator may throw. Unless you use the non-throwing variant.
2. Catching bad_alloc is something that is typically only done in two places:
1) At the top level of your program, to ensure graceful termination in OOM situations (there's not much you can do about them other than terminating).
2) Around areas that allocate an unusually large amount of memory. In such cases, you can just abort the memory-intensive operation and keep your program alive.