c++ - BOOST_FOREACH 在 boost::shared_ptr 上崩溃?

标签 c++ boost

试图对 shared_ptr 的 vector 做一个简单的操作,但它崩溃了?我怀疑我做错了什么?

std::vector< shared_ptr<SUBCLASS> > m_vecSections;

shared_ptr<SUBCLASS> hoodSection;
BOOST_FOREACH(hoodSection, m_vecSections ){
   //do something
}

我正在崩溃

 void add_ref_copy()
{
    atomic_increment( &use_count_ );
}

最佳答案

我认为你的语法应该是:

BOOST_FOREACH(shared_ptr<SUBCLASS> hoodSection , m_vecSections ){
   //do something
}

关于c++ - BOOST_FOREACH 在 boost::shared_ptr 上崩溃?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13357633/

相关文章:

c++ - 如何使用 DnsQuery 指定特定的 DNS 服务器进行查询?

c++ - boost::asio 从套接字读取 n 个字节到 streambuf

xcode - 在 MacOS Sierra 上找不到“openssl/conf.h”文件错误

c++ - 用于构建 boost : "don' t know how to make <e>stage"的“阶段”参数

c++ - 关于C++中的递归函数(初级)

c++ - 在 typedef 上使用 sizeof 而不是局部变量

#if - #endif 中的 C++ 行数限制?

c++ - 我如何从ptree异常中获取xml行号

c++ - 为什么 Boost 原子使用中的多生产者队列是无等待的

c++ - 在 C++ 哈希表代码中返回空迭代器