#pragma once
#include "GeometricMacro.h"
#include "GeometricEnum.h"
#include "McGePoint2d.h"
_GEOMETRIC_BEGIN
template<class T> inline bool clearvct(std::vector<T*>& vctVal)
{
for(std::vector<T*>::iterator p=vctVal.begin();p!=vctVal.end();++p)
{
delete static_cast<T*>(*p);
*p=NULL;
}
vctVal.clear();
return true;
}
template<class T> inline bool clearlst(std::list<T*>& lstVal)
{
for(std::list<T*>::iterator p=lstVal.begin();p!=lstVal.end();++p)
{
delete static_cast<T*>(*p);
*p=NULL;
}
lstVal.clear();
return true;
}
template<class T1,class T2> inline bool clearmap(std::map<T1,T2*>& mapVal)
{
for(std::map<T1,T2*>::iterator p=mapVal.begin();p!=mapVal.end();++p)
{
delete static_cast<T2*>(p->second);
static_cast<T2*>(p->second)=NULL;
}
mapVal.clear();
return true;
}
_GEOMETRIC_END
STL 的容器的清除模板 clear.h
最新推荐文章于 2018-05-31 15:45:28 发布