How might I wrap the FindXFile-style APIs to the STL-style Iterator Pattern in C++?

To solve the first problem, you can have end() return some sentinel value, then in your iterator’s increment function, set the iterator equal to that sentinel value when it reaches the end of the container. This is effectively what the directory iterator in Boost.Filesystem does.

For the second problem, I’m not entirely familiar with the FindXFile APIs, but one option would be to return some struct that contains all the data you need or that has member functions to get each of the pieces of data you might want.

Leave a Comment