I'm iterating some items like this quite a lot in my code:
for (; i != end; ++i) {
if(!restricted(*i))
{
doSomethingWithI(*i)
}
}
Is there a nicer way of doing this, perhaps with std or boost?
Another example:
for (; i != end; ++i) {
if(!restricted(*i))
{
Path p = _pathFactory->build(*i);
Value v = _db->load(p);
std::string output = _styler->style(v);
_output->write(output);
}
}
You can write a functor and use for_each.
In your code, at multiple places:
operator()() gets called on every element.
Functors are very flexible, you can templetize it, or you can pass parameters to it in the constructor.
There are also some default std functors you can use in the header.