fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4.  
  5.  
  6. class A {
  7. public:
  8. A(){
  9. cout << "constructor" << endl;
  10. throw 1;
  11. }
  12. };
  13.  
  14. void* operator new(size_t size, int i){
  15. cout << "in placement new" << endl;
  16. return ::operator new(size);
  17. }
  18.  
  19. void operator delete(void *ptr, int i){
  20. cout << "in placement delete" << endl;
  21. ::operator delete(ptr);
  22. }
  23.  
  24. int main(){
  25. int o = 9;
  26. try {
  27. A* a = new(o) A;
  28. } catch(...) {}
  29. }
  30.  
  31.  
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
in placement new
constructor
in placement delete