数据加载中……

DepClearVector DepCopyVector

#pragma  once
#include 
<vector>
using namespace std;
template 
<typename T>
bool DepCopyVector( const vector<T*>& src,vector<T*>& dest )
{
    
for (vector<T*>::const_iterator it=src.begin();
        it
!=src.end();
        
++it)
    
{
        T
*    pNew = new T;
        
if (pNew==NULL)
        
{
            
return false;
        }

        
*pNew = *(*it);
        dest.push_back(pNew);
    }

    
return true;
}


template 
<typename T>
void DepClearVector( vector<T*>& v )
{
    
for (vector<T*>::iterator it=v.begin();
        it
!=v.end();
        
++it)
    
{
        delete 
*it;
        
*it=NULL;
    }

    v.clear();
}

posted on 2011-07-05 11:16 Stone xin 阅读(200) 评论(0)  编辑 收藏 引用 所属分类: STL&&BOOST


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理