Boost logo

Boost Users :

From: Russell Hind (yg-boost-users_at_[hidden])
Date: 2003-06-10 02:43:43


> logger.cpp:36: error: no matching function for call to `
> boost::detail::thread::scoped_lock<boost::mutex>::scoped_lock(const
> boost::mutex&)'

If the mutex is a member variable, then in the const method, it is a
const mutex. scoped_lock requires a non-const mutex. This is what is
causing the error.

Declare the mutex as mutable so it appears as non-const even in const
members. (I don't know if this is the preferred way, but it is the way
I currently use).

It works if the mutex is declared in the .cpp because it is not part of
the class, and therefore isn't const when accessed inside a const method.

HTH

Russell


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net