Have you ever wanted to write your own C++ STL-style iterator? Of course you have. In some ways it’s easy, but getting all the boilerplate code correct can be a challenge. Fortunately, now there’s a great example that’s been put together by Ahmed Charles. He worked closely with some experts from the Microsoft Visual Studio team. You can find the end result here: http://blogs.msdn.com/b/vcblog/archive/2010/08/09/the-filterator.aspx
This iterator class performs a filter based upon a predicate you supply. The result is that you can iterate through just the items you care about in a given container.