This code won't compile:
class MyClass
{
boost::mutex _mutex;
void foo() const
{
boost::mutex::scoped_lock lock(_mutex);
//critical section
}
}
But defining the function as non const will work fine. Please, can someone explain why? Thanks!