Foreach implementation in C++, a Poor man's approach
<p>There are happy people working with boost and Qt. In my current "embedded" project I have to use home-made container classes. OK, enough complaining.</p>

<p>I've tried to implement an easy and self-contained foreach like that:</p>

<pre><code>#define ForEachString(S,C) TString S;\
        for ( int i=0; i&lt;C.GetSize() &amp;&amp; (!!(&amp;(S=C[i]))); ++i  )
</code></pre>

<p>It iterates through a string-list which has op[] and GetSize() methods. E.g.:</p>

<pre><code>TStringList tables;
ForEachString( table, tables )
{
  //do sth. with tab.
}
</code></pre>

<p>Of cause, the ugly thing is, each container type requires its own macro. 
Therefore my question: Is it possible to do it container independant and still self contained (all required stuff <strong>within</strong> the macro definition)?</p>

<p>Regards,
Valentin</p>
