diff --git a/wrap/Constructor.cpp b/wrap/Constructor.cpp index 9872d5fbe..323223a19 100644 --- a/wrap/Constructor.cpp +++ b/wrap/Constructor.cpp @@ -117,8 +117,10 @@ void Constructor::matlab_wrapper(const string& toolboxPath, file.oss << "void cleanup(void) {" << endl; //TODO: Remove //file.oss << " std::for_each( collector.begin(), collector.end(), Destruct() );" << endl; - file.oss << " BOOST_FOREACH(Shared* p, collector)" << endl; - file.oss << " collector.erase(p);" << endl; + file.oss << " for(std::set::iterator iter = collector.begin(); iter != collector.end(); ) {\n"; + file.oss << " delete *iter;\n"; + file.oss << " collector.erase(iter++);\n"; + file.oss << " }\n"; file.oss << "}" << endl; file.oss << "void mexFunction(int nargout, mxArray *out[], int nargin, const mxArray *in[])" << endl;