7

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).

The problem:

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

Here's the exact error I'm getting:

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?

OMGtechy
  • 7,935
  • 8
  • 48
  • 83
  • 2
    Related/possibly helpful: [cohabitation of boost::shared_ptr and std::shared_ptr](http://stackoverflow.com/questions/12314967/cohabitation-of-boostshared-ptr-and-stdshared-ptr) – user2802841 Mar 16 '14 at 23:28

2 Answers2

8

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.

OMGtechy
  • 7,935
  • 8
  • 48
  • 83
0

To the eyes of C++, and the compiler, std::weak_ptr and boost::weak_ptr are two completely different classes that has nothing in common. Therefore, when you are using boost::signals2 I'd suggest you to stick with boost::weak_ptr.

Shoe
  • 74,840
  • 36
  • 166
  • 272