Added workaround for MSVC limitation on number of consecutive loops

release/4.3a0
Richard Roberts 2012-07-23 21:27:40 +00:00
parent 0b08923c41
commit bcad0b661c
1 changed files with 4 additions and 2 deletions

View File

@ -558,13 +558,15 @@ void Module::WriteCollectorsAndCleanupFcn(FileWriter& wrapperFile, const std::st
const string cppName = cls.qualifiedName("::");
const string collectorType = "Collector_" + matlabUniqueName;
const string collectorName = "collector_" + matlabUniqueName;
// The extra curly-braces around the for loops work around a limitation in MSVC (existing
// since 2005!) preventing more than 248 blocks.
wrapperFile.oss <<
" for(" << collectorType << "::iterator iter = " << collectorName << ".begin();\n"
" { for(" << collectorType << "::iterator iter = " << collectorName << ".begin();\n"
" iter != " << collectorName << ".end(); ) {\n"
" delete *iter;\n"
" " << collectorName << ".erase(iter++);\n"
" anyDeleted = true;\n"
" }\n";
" } }\n";
}
wrapperFile.oss <<
" if(anyDeleted)\n"