混合提升智能指针和C ++ 11智能指针中的boost :: signals2 [英] Mixing boost smart pointers and C++11 smart pointers in boost::signals2

查看:118
本文介绍了混合提升智能指针和C ++ 11智能指针中的boost :: signals2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用应用程序的boost :: signals2 来组件之间的通信。我试图用它通过 slot_type(...)的自动连接管理功能。音轨(weak_ptr的)

I have an application which uses boost::signals2 to communicate between components. I am trying to use it's automatic connection management features through slot_type(...).track(weak_ptr).

问题:

在我的整个程序,的std :: shared_ptr的被使用。 .track 需要一个的boost :: weak_ptr的,而我提供了一个的std :: weak_ptr的

Throughout my program, std::shared_ptr is used. .track expects a boost::weak_ptr, and I am providing an std::weak_ptr.

这里是我得到确切的错误:

cannot convert argument 1 from 'std::weak_ptr<_Ty>' to 'const boost::weak_ptr<void> &'

对此有一个解决方法吗?或者我误解了问题?

Is there a workaround for this? Or have I misunderstood the problem?

推荐答案

我找到了一个解决方案,它是使用 .track_foreign 而不是 .track 。它允许在地方升压智能指针的使用C ++ 11的智能指针。

I found a solution, and it was to use .track_foreign instead of .track. It allows the use of C++11 smart pointers in place of the boost smart pointers.

这篇关于混合提升智能指针和C ++ 11智能指针中的boost :: signals2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆