小编Les*_*ieg的帖子

shared_ptr的基本语法问题

我是shared_ptr的新手.我有几个关于C++ 0x shared_ptr语法的问题,如下所示:

//first question
shared_ptr<classA>ptr(new classA()); //works
shared_ptr<classA>ptr;
ptr = ?? //how could I create a new object to assign it to shared pointer?


//second question
shared_ptr<classA>ptr2; //could be tested for NULL from the if statement below
shared_ptr<classA> ptr3(new classA());
ptr3 = ?? //how could I assign NULL again to ptr3 so that the if statement below becomes true?

if(!ptr3) cout << "ptr equals null";
Run Code Online (Sandbox Code Playgroud)

c++

6
推荐指数
2
解决办法
3237
查看次数

在C++中同步unordered_map

我正在使用Boost的unordered_map.是否有unordered_map的同步版本?这是因为我有相当大量的unordered_map并使用锁手动同步这将是非常混乱的.

谢谢.

c++ stl

3
推荐指数
1
解决办法
2405
查看次数

标签 统计

c++ ×2

stl ×1