boost::intrusive_ptr 的问题

发布于 2024-11-28 05:43:09 字数 615 浏览 1 评论 0原文

有一个包含 intrusive_ptr 字段的结构:

struct BranchFeedback : boost::counted_base {
  ...
  boost::intrusive_ptr<BPredState> theBPState;
};

还有另一个变量定义为

std::vector< std::vector< BPredState > >           theFetchState;

现在我已经实例化了一个对象

BranchFeedback theFeedback;

并希望将 theFetchState 分配给该字段

theFeedback.theBPState = theFetchState[anIndex][!anOne];

但是编译器显示一些错误

error: no match for ‘operator=’ in theFeedback.theBPState = .....

我该如何解决这个问题?

There is a struct which contain intrusive_ptr field:

struct BranchFeedback : boost::counted_base {
  ...
  boost::intrusive_ptr<BPredState> theBPState;
};

There is another varibale which is defined as

std::vector< std::vector< BPredState > >           theFetchState;

Now I have instantiated an object

BranchFeedback theFeedback;

and want to assign theFetchState to that field

theFeedback.theBPState = theFetchState[anIndex][!anOne];

However compiler says some errors

error: no match for ‘operator=’ in theFeedback.theBPState = .....

How can I fix that?

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

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

发布评论

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

评论(1

如梦亦如幻 2024-12-05 05:43:09

您传递的是 BPredState,但仅 intrusive_ptr支持用于指向所包含类型(或其他 intrusive_ptr)的指针的 operator=,

因此您可以编写 BPState = &(theFetchState[anIndex][!anOne]);或者获取指向该元素的指针或迭代器并使用它。

you're passing in a BPredState, but intrusive_ptr only supports operator= for pointers to the contained type (or other intrusive_ptrs)

so you could write theBPState = &(theFetchState[anIndex][!anOne]); or get an pointer or iterator to the element and use that instead.

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