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 here
This 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.