#include <iostream>
#include <list>
#include <algorithm>
#include <memory>
class Hoge {
public:
int *hoge;
struct {
int hoge;
} hage;
Hoge(int hoge) {
this->hoge = new(std::nothrow) int;
if (this->hoge)
*(this->hoge) = hoge;
hage.hoge = (hoge % 3 == 0) ? true : false;
}
~Hoge() { delete hoge; }
};
// not used <functional>
class HogeP {
public:
bool operator()(Hoge *hoge) {
struct Hage {
bool hoge;
} hage;
if ((hage.hoge = hoge->hage.hoge) == true) delete hoge;
return hage.hoge;
}
};
class HogeS {
public:
void operator()(Hoge *hoge) { std::cout << *(hoge->hoge) << std::endl; }
};
int main() {
struct {
int hoge;
} hage;
std::list<Hoge *> hoge;
for (hage.hoge = 0; hage.hoge < 10; hage.hoge++)
hoge.push_back(new(std::nothrow) Hoge(hage.hoge));
for_each(hoge.begin(), hoge.end(), HogeS());
hoge.remove_if(HogeP());
hoge.erase(remove_if(hoge.begin(), hoge.end(), HogeP()), hoge.end());
for_each(hoge.begin(), hoge.end(), HogeS());
while (!hoge.empty()) {
delete *(hoge.begin());
hoge.pop_front();
}
return 0;
}
/* end */