Reputation: 53119
This is really weird. First I didn't know that you can delete functions and second, this happens in external library.
The circumstances of the error are that I'm using QtCreator to build project AND boost all together, without any static libs whatsoever.
The compiler used is gcc
myprogram.h:4:7: error: use of deleted function 'boost::shared_mutex::shared_mutex(const boost::shared_mutex&)'
In file included from ../libs/boost155/boost/thread/lock_guard.hpp:11:0,
from ../libs/boost155/boost/thread/pthread/thread_data.hpp:11,
from ../libs/boost155/boost/thread/thread_only.hpp:17,
from ../libs/boost155/boost/thread/thread.hpp:12,
from ../libs/boost155/boost/thread.hpp:13,
from myprogram.h:2,
from myprogram.cpp:1:
Upvotes: 0
Views: 3427
Reputation: 12058
First I didn't know that you can delete functions
C++ 11 allows that:
struct noncopyable
{
noncopyable(const noncopyable&) =delete;
noncopyable& operator=(const noncopyable&) =delete;
};
Another similar feature are functions marked as default (=default
). Good article on MSDN about deleted and defaulted functions: click.
second, this happens in external library.
You try to copy shared_mutex
from that library - that is not possible. Think about it - what would "mutex copy" represent?
Probably you have some code, that introduces copying - do you store some objects containing mutexes in std::
containers?
Upvotes: 0
Reputation: 392833
You're trying to copy a mutex. That is not possible.
You're triggering that from
from myprogram.h:2,
from myprogram.cpp:1:
So, that's your code. Probably, if it is not explicit in your code, you have a shared_mutex
as a member in a class, and this class is getting copied, somewhere as part of the rest of the code.
E.g.:
struct MyClass {
boost::shared_mutex sm;
};
std::vector<MyClass> v;
// etc.
vector
will copy.move its elements during many operations and this would trigger the mutex copy along the way.
For background:
Upvotes: 4