That seems to have solved the problem. Thanks very much.
On Fri, Sep 18, 2009 at 6:21 PM, Wesley Bland <wesbland@gmail.com> wrote:
This is firmly in n00b territory.I'm trying to use a boost::mutex to lock a STL queue. The mutex is stored in a class in a map. When I pass the mutex to the boost::mutex::scoped_lock constructor, I get this error:
/usr/local/include/boost/noncopyable.hpp: In copy constructor ‘boost::mutex::mutex(const boost::mutex&)’:/usr/local/include/boost/thread/pthread/mutex.hpp:31: instantiated from ‘_Tp& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](const _Key&) [with _Key = int, _Tp = boost::mutex, _Compare = std::less<int>, _Alloc = std::allocator<std::pair<const int, boost::mutex> >]’SwitchBox.cpp:15: instantiated from here/usr/local/include/boost/noncopyable.hpp:27: error: ‘boost::noncopyable_::noncopyable::noncopyable(const boost::noncopyable_::noncopyable&)’ is private/usr/local/include/boost/thread/pthread/mutex.hpp:31: error: within this context/usr/include/c++/4.2.1/bits/stl_map.h: In member function ‘_Tp& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](const _Key&) [with _Key = int, _Tp = boost::mutex, _Compare = std::less<int>, _Alloc = std::allocator<std::pair<const int, boost::mutex> >]’:/usr/include/c++/4.2.1/bits/stl_map.h:350: note: synthesized method ‘boost::mutex::mutex(const boost::mutex&)’ first required hereThis appears to be complaining about me passing the mutex into the scoped_lock. Can anyone give me some help here? I've included a much shortened version of the code that otherwise compiles.
It's complaining about the mutex being in a map. The map requires the elements within it to be copy constructable which boost::mutex isn't by design. You might want to consider using a shared_ptr<mutex>.
Thanks for your help,Wesley
<snip code />
Regards,
Neil Groves
_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users