Sunday, October 31, 2010

CppIterator tool = C# IEnumerable for C++

If we need to find all substrings for a given string, retrieve file names from a directory or iterate list/tree structure in C++ we write iterators... State machinery with a pile of other boilerplate code behind implementation of iterators - conceals programmer's intentions. The idea to write only necessary code for iteration is implemented in C# language when programmer writes IEnumerable method with yield statements and a compiler generates underlying IEnumerator machinery and embeds it in a host assembly. Evidently, in theory, we can do the same trick in C++.

No comments:

Post a Comment