迭代 boost ptr_vector

发布于 2024-09-03 06:05:06 字数 306 浏览 2 评论 0原文

我有一个我自己的对象的 ptr_vector 列表。像这样的事情:

boost::ptr_vector<SomeClass> *list;
list->push_back(new SomeClass()>;
...
BOOST_FOREACH(SomeClass *tempObj, list)   // [x]
{
   tempObj->...
}


>‘boost::ptr_vector<SomeClass>*’ is not a class, struct, or union type

I have a ptr_vector list of my own objects. Something like this:

boost::ptr_vector<SomeClass> *list;
list->push_back(new SomeClass()>;
...
BOOST_FOREACH(SomeClass *tempObj, list)   // [x]
{
   tempObj->...
}


>‘boost::ptr_vector<SomeClass>*’ is not a class, struct, or union type

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

白况 2024-09-10 06:05:06

我认为您的问题是您将“list”声明为指向 boost::ptr_vector 的指针,并尝试将其用作自动对象。

恕我直言,代码片段的第一行应为:

boost::ptr_vector<SomeClass> list;

I think your problem is that you declared 'list' as a pointer to a boost::ptr_vector and are trying to use it as an automatic object.

IMHO the first line of your code snippet should read:

boost::ptr_vector<SomeClass> list;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文