fork(1) download
  1. #include <iostream>
  2. #include <cstring>
  3. #include <cstddef>
  4.  
  5. const size_t CHONK_SIZE = 1000000;
  6.  
  7. template<typename T>
  8. class chonk
  9. {
  10. public:
  11. chonk() : pc(new T[CHONK_SIZE]) {}
  12.  
  13. chonk(const chonk& rhs)
  14. : pc(new T[CHONK_SIZE])
  15. {
  16. memcpy(pc, rhs.pc, CHONK_SIZE*sizeof(T));
  17. }
  18.  
  19. chonk& operator=(const chonk& rhs)
  20. {
  21. delete[] pc;
  22. pc = new T[CHONK_SIZE];
  23. memcpy(pc, rhs.pc, CHONK_SIZE*sizeof(T));
  24. return *this;
  25. }
  26.  
  27. private:
  28. T* pc;
  29. };
  30.  
  31. int main()
  32. {
  33. chonk<int> ci;
  34. chonk<float> cf;
  35. chonk<float> cg { cf };
  36. }
  37.  
Success #stdin #stdout 0.01s 5284KB
stdin
Standard input is empty
stdout
Standard output is empty