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.
I’ve tried to implement an easy and self-contained foreach like that:
#define ForEachString(S,C) TString S;\
for ( int i=0; i<C.GetSize() && (!!(&(S=C[i]))); ++i )
It iterates through a string-list which has op[] and GetSize() methods. E.g.:
TStringList tables;
ForEachString( table, tables )
{
//do sth. with tab.
}
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 within the macro definition)?
Regards,
Valentin
Perhaps you could parameterise on the type T: