Currently, I am removing Boost dependencies from a project. I have replaced boost::function
and boost::ref
with std::function
and std::ref
, respectively. I was able to build the project, but in case of executing it catch through an exception and getting freeze the functionality.
Further, after replacing boost::function
with std::function
, it cannot compare std::function<void()>
directly with a static void method.
Does anyone have a suggestion on this?
bool NotificationQueue::evoke(boost::function<void()> runner) {
if (runner == &Sentinel::stop) {
return false;
}
}
this worked with boost perfect and when I replaced boost with std these changes had been done
bool NotificationQueue::evoke(function<void()> runner) {
if (runner.target<void()>() == &Sentinel::stop) {
return false;
}
Also the following error get throws
static void stop() { throw std::logic_error("stop sentinel should not be executed"); }
where I have included this stop method in the following code
_stopFn(&Sentinel::stop)
void NotificationQueue::postStop() {
postNotification(ref(_stopFn));
unique_lock<mutex> lock(_mutex);
if (!_notificationEnabled) {
_stopped = true;
_enabledNotifier.notify_all();
}
}
the above ref was previously was in boost::ref