1

这是我的场景

boost::condition_variable        _condition;
boost::unique_lock<boost::mutex> lock(_mutex);
boost::detail::atomic_count      _count;
.........
_condition.wait(&lock, boost::bind(std::less<int>(), boost::ref(_count), max));

得到错误

error: no matching function for call to 'boost::condition_variable::wait(boost::unique_lock<boost::mutex>*, boost::_bi::bind_t<boost::_bi::unspecified, std::less<int>, boost::_bi::list2<boost::reference_wrapper<boost::detail::atomic_count>, boost::_bi::value<short unsigned int> > >)'

问题出在哪里 ?

4

1 回答 1

1

condition_variable::wait() accepts a single argument

void wait(boost::unique_lock<boost::mutex>& lock)

or the two argument case with a predicate type

template<typename predicate_type> void wait(boost::unique_lock<boost::mutex>& lock, predicate_type pred)

In either case, the first argument is a reference not a pointer as in your example.

于 2012-07-22T13:41:41.500 回答