Stl std::tr1::shared_ptr 自定义析构器

//删除器类

class ObjDelecter
{
public:
  void operator()(SNpcStateBindData* pData)
  {
    delete pData;
    pData = 0;
  }
};

//定义

typedef std::tr1::shared_ptr<SNpcStateBindData>    SNpcStateBindDataPtr;

typedef std::vector< SNpcStateBindDataPtr >      NpcStateDataPtrList;

//声明

NpcStateDataPtrList  m_vNpcStateBindDataList;

//添加

m_vNpcStateBindDataList.push_back( SNpcStateBindDataPtr(new SNpcStateBindData( ...paramaters... ), ObjDelecter() ) );

你可能感兴趣的:(自定义)