fork download
  1. #include <iterator>
  2. #include <numeric>
  3. #include <iostream>
  4.  
  5. class Example
  6. {
  7. private:
  8. int id;
  9. public:
  10. Example(int i=0): id(i){std::cout<<"ctor: "<<i<<std::endl;}
  11. ~Example(){std::cout<<"dtor: "<<id<<std::endl;}
  12. };
  13.  
  14. int main() {
  15. Example e[10];
  16. std::cout<<"call iota"<<std::endl;
  17. std::iota(std::begin(e), std::end(e), 0);
  18. std::cout<<"call iota finished"<<std::endl;
  19. return 0;
  20. }
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
ctor: 0
ctor: 0
ctor: 0
ctor: 0
ctor: 0
ctor: 0
ctor: 0
ctor: 0
ctor: 0
ctor: 0
call iota
ctor: 0
dtor: 0
ctor: 1
dtor: 1
ctor: 2
dtor: 2
ctor: 3
dtor: 3
ctor: 4
dtor: 4
ctor: 5
dtor: 5
ctor: 6
dtor: 6
ctor: 7
dtor: 7
ctor: 8
dtor: 8
ctor: 9
dtor: 9
call iota finished
dtor: 9
dtor: 8
dtor: 7
dtor: 6
dtor: 5
dtor: 4
dtor: 3
dtor: 2
dtor: 1
dtor: 0