I have a templated class that uses ofScopedLock, it’s a mutexed list like so:
template <typename T>
int queueSize = queue.size();
When I try to implement the
size() function with an ofScopedLock VS2012 gives me :
Error 197 error C2248: ‘Poco::ScopedLock::ScopedLock’ : cannot access private member declared in class ‘Poco::ScopedLock’
The same with some other functions. Any idea why?
can you post the code that fails?
Argh, my bad.
This didn’t work:
I probably have another mutex with the same name somewhere in a derived class.
yes there’s now
std::mutex and since we include the whole std namespace that can be problematic at times we should rename that mutex to mtx or similar.
by the way, i think this:
won’t work since the scope of an anonimous variable is just the line in which it’s defined so it’ll go away immediately unlocking the mutex after that line. you need to create a variable that lasts until the end of that block:
also this is now present in the stl so it’s better to use that directly:
…Good thing to know about anonimous variables.
Actually there was another reason to get that error, it’s that my class did not define a copy constructor for my class and the compiler wasn’t able to generate one while using std::mutex (or Poco::FastMutex).
I just created an empty copy constructor, I wasn’t able to make it private or declare it as