Neapolitan
4 years ago
This blog is unwritable. The blog of Owen Roberts.
class Base
{
public:
virtual ~Base(){};
typedef std::list List;
struct Functor
{
virtual ~Functor(){}
virtual void operator()(Base& o) const=0;
};
static void Functorator(List& l, const Functor& f)
{
std::for_each(l.begin(), l.end(), f);
}
};
//Don't keep writing list loops, use functors!
class Base
{
public:
virtual ~Base(){};
typedef std::list List;
struct Functor
{
virtual ~Functor(){}
virtual void operator()(Base& o) const=0;
};
static void Functorator(List& l, const Functor& f)
{
for (List::iterator it=l.begin();
it!=l.end(); ++it)
{
f(*(*it));
}
}
};