0
我對shared_ptr和mutex這兩個概念都不熟悉(boost或not boost)。我想在我的班級使用它:'boost shared_ptr'和'boost lock'together =搞砸了
typedef boost::shared_mutex Lock;
typedef boost::unique_lock<Lock> WriteLock;
typedef boost::shared_lock<Lock> ReadLock;
class subscriptionInfo
{
public:
//this is not a copy constructible class. so I have to use shared pointer
boost::shared_ptr<Lock> myLock;
...
}
...
std::vector<DATA_MSG_PTR>& subscriptionInfo::getIncoming() {
ReadLock Lock(myLock);
return incoming;
}
和錯誤說:
error: no matching function for call to ‘boost::shared_lock<boost::shared_mutex>::shared_lock(boost::shared_ptr<boost::shared_mutex>&)’
,如果你幫我找出我搞砸了,如何解決這個問題,我會感激。 謝謝