#include <cstdlib>
#include <iostream>
#include <list>
using namespace std;
struct Hoge
{
bool hello(list<Hoge> & h)
{
cout << "hello" << endl;
if(rand() % 20 == 0) h.push_back(Hoge());
return rand() % 10 == 0;
}
};
int main(void)
{
list<Hoge> h(15);
while(!h.empty())
{
list<Hoge>::iterator i = h.begin(), e = h.end();
while(i != e) if(i->hello(h)) i = h.erase(i); else ++i;
}
return 0;
}