|
Boost Users : |
From: Darren Vincent Hart (dvhart_at_[hidden])
Date: 2003-06-09 19:25:33
Esteemed Boost Gurus,
I am trying to compile a method with a scoped_lock call. If I use a
mutex object declared in the class implementation file (logger.cpp) it
builds, if I use a mutex of the same type declared as a private member
of the logger class (in logger.h), I get the following compiler error:
logger.cpp: In member function `void pel::logger::info(const
std::string&,
const std::string&, int, const std::string&) const':
logger.cpp:36: error: no matching function for call to `
boost::detail::thread::scoped_lock<boost::mutex>::scoped_lock(const
boost::mutex&)'
/usr/include/boost/thread/detail/lock.hpp:62: error: candidates are:
boost::detail::thread::scoped_lock<boost::mutex>::scoped_lock(const
boost::detail::thread::scoped_lock<boost::mutex>&)
/usr/include/boost/thread/detail/lock.hpp:67: error:
boost::detail::thread::scoped_lock<Mutex>::scoped_lock(Mutex&, bool =
true)
[with Mutex = boost::mutex]
make: *** [logger.o] Error 1
The relevant method from the implementation file is as follows:
void logger::info(const std::string& msg, const std::string& file, int
line, const std::string& function) const
{
// io_mutex is declared above in the pel namespace
boost::mutex::scoped_lock scoped_lock(io_mutex); // no problem
// mutex is a private member of the logger class
boost::mutex::scoped_lock scoped_lock2(mutex); // line 36, fails
std::cout << "...blah..." << std::endl;
}
Can someone explain why these are treated differently by the compiler ?
Thanks,
Darren Hart
dvhart_at_[hidden]
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