Boost :: lock does not compile in boost 1.53

I am compiling a project. It has the following lines:

boost::mutex::scoped_lock ml(m_meta_mut, boost::defer_lock); boost::mutex::scoped_lock tl(m_tables_mut, boost::defer_lock); boost::lock(ml, tl); 

I get lock is not a member of boost in the third line. I am using boost1.53 (the project recommends 1.49)

What is the problem

+4
source share
1 answer

Turning my comment into a more complete answer. The boost::lock() functions are defined in boost / thread / locks.hpp . When you see a compiler error

lock is not a boost element

This means that the compiler cannot find the lock() function in the boost namespace. The solution is to add #include <boost/thread.locks.hpp> to any translation unit that you are compiling. I do not see changes in this header from boost 1.49 to increase 1.53, although I did not look wide. Subject to change of directives.

+3
source

Source: https://habr.com/ru/post/1488129/


All Articles