boost::intrusive_ptr 的问题
有一个包含 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技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您传递的是 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.