Two small issues with this implementation:
1. Using try catch as loop control IMO not very nice.
2. If you loop until std::numeric_limits<size_t>::max() you might as well write while(true). I would do it like this...
```c++
for (size_t i = 0; i < nT; i++) {
  candidate = getEntity(i);
  if (candidate && filter(candidate)
    entities.push_back(candidate);
}
```
This should not throw an exception at all, or am I totally wrong?

And another minor thing: please use a bit more K&R like code style.