fork(1) download
  1. #include <iostream>
  2.  
  3. class SimpleMemoryPool{
  4. };
  5.  
  6. void* operator new(size_t n, SimpleMemoryPool* pool)
  7. {
  8. std::cout << __func__ << std::endl;
  9. void *tmp = ::operator new(n);
  10. return tmp;
  11. }
  12.  
  13. void* operator new[](size_t n , SimpleMemoryPool* pool)
  14. {
  15. std::cout << __func__ << std::endl;
  16. void *tmp = ::operator new(n);
  17. return tmp;
  18. }
  19.  
  20. int main()
  21. {
  22. SimpleMemoryPool *m_Pool;
  23. float *signalGen = new (m_Pool) float[100];
  24. SimpleMemoryPool *p = new (m_Pool) SimpleMemoryPool();
  25. delete[] signalGen;
  26. delete p;
  27. }
Success #stdin #stdout 0s 4292KB
stdin
Standard input is empty
stdout
operator new []
operator new