There are four usage of new: 1) throw bad_alloc exception. 2) no throw, but
return nullptr(sinnce c++11) 3)placement New(not allocate, just cotr)
4)operator new(just allocate, no ctor)
In you customized error_handler Just for your certain class. You can’t call
set_new_handle in main, it will affect all the new in global scope. You
should overwrite you own operator new in your class. like below:
construct an object in memory you’ve already got a pointer to ,use
placement new. If you use placement new to create an object in some
memory, you should avoid using the delete operator on that memory. Detail
can be seen in C++ primer