Tag: share_ptr

  • share_ptr加入stl

    #include <string>#include <vector>#include <memory>#include <map> template <class T>using SPVEC = std::vector<std::shared_ptr<T>>; template <class T1, class T2>using SPMAP = std::map<T1, std::shared_ptr<T2>>; const size_t LEN = 1024 * 1024 ; class TestUnit{public:    TestUnit(int _id);    ~TestUnit(); private:    int m_id;    std::string m_buf;}; TestUnit::TestUnit(int _id):m_id(_id){    m_buf.resize(LEN, 0);    printf(“%d construction\n”,m_id);} TestUnit::~TestUnit(){    printf(“%d destruction\n”, m_id);} int main(int argc, char** argv) {       {        […]