NULL pointer with boost::shared_ptr?

后端 未结 6 1007
悲哀的现实
悲哀的现实 2020-12-12 20:35

What\'s the equivalent to the following:

std::vector vec;
vec.push_back(NULL);

when dealing with boost::shared_ptr

6条回答
  •  醉梦人生
    2020-12-12 21:14

    In C++0x, you can simply convert from nullptr to std::shared_ptr:

    std::vector< boost::shared_ptr > vec;
    vec.push_back(nullptr);
    

提交回复
热议问题