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,445
  • 8
  • 46
  • 80

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,445
  • 8
  • 46
  • 80
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
  • 72,892
  • 33
  • 161
  • 264