fork download
  1. #include <iostream>
  2.  
  3. struct Deleter {
  4. template <class T> Deleter & operator , (T *p) {
  5. delete p;
  6. return *this;
  7. }
  8. operator void *() {
  9. return 0;
  10. }
  11. } d;
  12.  
  13. struct Test {
  14. Test() { std::cout << "Test::Test()" << std::endl; }
  15. ~Test() { std::cout << "Test::~Test()" << std::endl; }
  16. };
  17.  
  18. int main() {
  19. Test &t1 = *new Test();
  20. Test &t2 = *new Test();
  21. delete (d, &t1, &t2);
  22. return 0;
  23. }
Success #stdin #stdout 0s 3472KB
stdin
Standard input is empty
stdout
Test::Test()
Test::Test()
Test::~Test()
Test::~Test()